Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
|
|
| 1 |
from huggingface_hub import InferenceClient
|
| 2 |
|
| 3 |
-
#
|
| 4 |
client = InferenceClient()
|
| 5 |
|
| 6 |
@tool
|
|
@@ -13,11 +14,11 @@ def generate_image(description: str) -> str:
|
|
| 13 |
str: A URL to the generated image.
|
| 14 |
"""
|
| 15 |
try:
|
| 16 |
-
#
|
| 17 |
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 18 |
result = client.text_to_image(model=model_id, prompt=description)
|
| 19 |
|
| 20 |
-
#
|
| 21 |
if 'url' in result[0]:
|
| 22 |
return f"Here's your generated image: {result[0]['url']}"
|
| 23 |
else:
|
|
|
|
| 1 |
+
from smolagents import tool # Ensure 'tool' is imported from smolagents
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
# Initialize the InferenceClient
|
| 5 |
client = InferenceClient()
|
| 6 |
|
| 7 |
@tool
|
|
|
|
| 14 |
str: A URL to the generated image.
|
| 15 |
"""
|
| 16 |
try:
|
| 17 |
+
# Replace with the correct model
|
| 18 |
model_id = "stabilityai/stable-diffusion-xl-base-1.0"
|
| 19 |
result = client.text_to_image(model=model_id, prompt=description)
|
| 20 |
|
| 21 |
+
# Check if 'url' is in the result and return it
|
| 22 |
if 'url' in result[0]:
|
| 23 |
return f"Here's your generated image: {result[0]['url']}"
|
| 24 |
else:
|