Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,12 +2,11 @@ import gradio as gr
|
|
| 2 |
import os
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
-
# 🔑
|
| 6 |
-
HF_TOKEN = os.
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
HF_TOKEN = ""
|
| 11 |
|
| 12 |
client = InferenceClient(
|
| 13 |
model="stabilityai/stable-diffusion-xl-base-1.0",
|
|
@@ -16,10 +15,10 @@ client = InferenceClient(
|
|
| 16 |
|
| 17 |
def generate_image(prompt):
|
| 18 |
if not prompt.strip():
|
| 19 |
-
return None, "⚠️ Enter
|
| 20 |
|
| 21 |
if not HF_TOKEN:
|
| 22 |
-
return None, "❌
|
| 23 |
|
| 24 |
try:
|
| 25 |
image = client.text_to_image(prompt)
|
|
|
|
| 2 |
import os
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
# 🔑 Read secret safely
|
| 6 |
+
HF_TOKEN = os.environ.get("images")
|
| 7 |
|
| 8 |
+
def check_token():
|
| 9 |
+
return HF_TOKEN is not None
|
|
|
|
| 10 |
|
| 11 |
client = InferenceClient(
|
| 12 |
model="stabilityai/stable-diffusion-xl-base-1.0",
|
|
|
|
| 15 |
|
| 16 |
def generate_image(prompt):
|
| 17 |
if not prompt.strip():
|
| 18 |
+
return None, "⚠️ Enter prompt"
|
| 19 |
|
| 20 |
if not HF_TOKEN:
|
| 21 |
+
return None, "❌ Secret not loaded. Restart Space again."
|
| 22 |
|
| 23 |
try:
|
| 24 |
image = client.text_to_image(prompt)
|