Update app.py
Browse files
app.py
CHANGED
@@ -4,15 +4,12 @@ import numpy as np
|
|
4 |
import re
|
5 |
import torch
|
6 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
7 |
-
from huggingface_hub import snapshot_download
|
8 |
import logging
|
9 |
import os
|
10 |
import spaces
|
11 |
import warnings
|
12 |
from snac import SNAC
|
13 |
-
from dotenv import load_dotenv
|
14 |
-
|
15 |
-
load_dotenv()
|
16 |
|
17 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
18 |
logger = logging.getLogger(__name__)
|
@@ -40,7 +37,7 @@ def load_model():
|
|
40 |
|
41 |
snapshot_download(
|
42 |
repo_id=model_name,
|
43 |
-
use_auth_token=os.environ.get("
|
44 |
allow_patterns=["config.json", "*.safetensors", "model.safetensors.index.json", "vocab.json", "merges.txt", "tokenizer.json"],
|
45 |
ignore_patterns=["optimizer.pt", "pytorch_model.bin", "training_args.bin", "scheduler.pt"]
|
46 |
)
|
@@ -57,7 +54,7 @@ def load_model():
|
|
57 |
def generate_podcast_script(api_key, content, uploaded_file, duration, num_hosts):
|
58 |
try:
|
59 |
genai.configure(api_key=api_key)
|
60 |
-
model = genai.GenerativeModel('gemini-
|
61 |
|
62 |
combined_content = content or ""
|
63 |
if uploaded_file:
|
@@ -249,6 +246,6 @@ with gr.Blocks() as demo:
|
|
249 |
if __name__ == "__main__":
|
250 |
try:
|
251 |
load_model()
|
252 |
-
demo.queue().launch(
|
253 |
except Exception as e:
|
254 |
logger.error(f"Error launching the application: {str(e)}")
|
|
|
4 |
import re
|
5 |
import torch
|
6 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
7 |
+
from huggingface_hub import snapshot_download
|
8 |
import logging
|
9 |
import os
|
10 |
import spaces
|
11 |
import warnings
|
12 |
from snac import SNAC
|
|
|
|
|
|
|
13 |
|
14 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
15 |
logger = logging.getLogger(__name__)
|
|
|
37 |
|
38 |
snapshot_download(
|
39 |
repo_id=model_name,
|
40 |
+
use_auth_token=os.environ.get("HF_TOKEN"),
|
41 |
allow_patterns=["config.json", "*.safetensors", "model.safetensors.index.json", "vocab.json", "merges.txt", "tokenizer.json"],
|
42 |
ignore_patterns=["optimizer.pt", "pytorch_model.bin", "training_args.bin", "scheduler.pt"]
|
43 |
)
|
|
|
54 |
def generate_podcast_script(api_key, content, uploaded_file, duration, num_hosts):
|
55 |
try:
|
56 |
genai.configure(api_key=api_key)
|
57 |
+
model = genai.GenerativeModel('gemini-pro')
|
58 |
|
59 |
combined_content = content or ""
|
60 |
if uploaded_file:
|
|
|
246 |
if __name__ == "__main__":
|
247 |
try:
|
248 |
load_model()
|
249 |
+
demo.queue().launch()
|
250 |
except Exception as e:
|
251 |
logger.error(f"Error launching the application: {str(e)}")
|