Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ from PIL import Image
|
|
8 |
import gradio as gr
|
9 |
|
10 |
# Login with Hugging Face token
|
11 |
-
hf_token = os.getenv("HUGGINGFACE_API_KEY")
|
12 |
if hf_token:
|
13 |
login(token=hf_token, add_to_git_credential=True)
|
14 |
else:
|
@@ -33,7 +33,7 @@ def translate_text(text, src_lang, tgt_lang):
|
|
33 |
|
34 |
# Image generation with reduced resolution
|
35 |
flux_API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|
36 |
-
flux_headers = {"Authorization": f"Bearer {
|
37 |
def generate_image(prompt):
|
38 |
try:
|
39 |
response = requests.post(flux_API_URL, headers=flux_headers, json={"inputs": prompt})
|
@@ -49,7 +49,7 @@ def generate_image(prompt):
|
|
49 |
|
50 |
# Creative text generation with reduced length
|
51 |
mistral_API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-v0.1"
|
52 |
-
mistral_headers = {"Authorization": f"Bearer {
|
53 |
def generate_creative_text(translated_text):
|
54 |
try:
|
55 |
response = requests.post(mistral_API_URL, headers=mistral_headers, json={"inputs": translated_text, "max_length": 30})
|
|
|
8 |
import gradio as gr
|
9 |
|
10 |
# Login with Hugging Face token
|
11 |
+
hf_token = os.getenv("HUGGINGFACE_API_KEY") # Updated variable name
|
12 |
if hf_token:
|
13 |
login(token=hf_token, add_to_git_credential=True)
|
14 |
else:
|
|
|
33 |
|
34 |
# Image generation with reduced resolution
|
35 |
flux_API_URL = "https://api-inference.huggingface.co/models/black-forest-labs/FLUX.1-dev"
|
36 |
+
flux_headers = {"Authorization": f"Bearer {hf_token}"}
|
37 |
def generate_image(prompt):
|
38 |
try:
|
39 |
response = requests.post(flux_API_URL, headers=flux_headers, json={"inputs": prompt})
|
|
|
49 |
|
50 |
# Creative text generation with reduced length
|
51 |
mistral_API_URL = "https://api-inference.huggingface.co/models/mistralai/Mistral-7B-v0.1"
|
52 |
+
mistral_headers = {"Authorization": f"Bearer {hf_token}"}
|
53 |
def generate_creative_text(translated_text):
|
54 |
try:
|
55 |
response = requests.post(mistral_API_URL, headers=mistral_headers, json={"inputs": translated_text, "max_length": 30})
|