Spaces:
Runtime error
Runtime error
Commit ·
88706c5
1
Parent(s): 878e799
images added
Browse files- app.py +21 -12
- images/image1.jpeg +0 -0
- images/image2.jpeg +0 -0
- images/image3.jpeg +0 -0
- images/image4.jpeg +0 -0
- images/image5.jpeg +0 -0
- images/image6.jpeg +0 -0
- images/image7.jpeg +0 -0
- images/image8.jpeg +0 -0
- images/image9.jpeg +0 -0
- images/prompts.json +11 -0
app.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
-
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import io
|
| 5 |
-
from PIL import Image
|
| 6 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
HF_API_KEY = os.getenv("HF_TOKEN")
|
| 8 |
API_URL = "https://api-inference.huggingface.co/models/sameedhayat/corgy_dog_LoRA"
|
| 9 |
headers = {"Authorization": f"Bearer {HF_API_KEY}"}
|
|
@@ -37,15 +39,21 @@ def generate_image(user_text):
|
|
| 37 |
return f"Error generating image: {str(e)}"
|
| 38 |
|
| 39 |
def fetch_showcase_images():
|
| 40 |
-
"""Fetch images from the
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
# Extracting images from the discussion (Placeholder logic)
|
| 46 |
-
return ["https://picsum.photos/200/300"] # Replace with actual parsing logic
|
| 47 |
-
else:
|
| 48 |
-
return []
|
| 49 |
|
| 50 |
def create_interface():
|
| 51 |
showcase_images = fetch_showcase_images()
|
|
@@ -61,8 +69,9 @@ def create_interface():
|
|
| 61 |
btn.click(generate_image, inputs=user_input, outputs=output_image)
|
| 62 |
|
| 63 |
gr.Markdown("### 🎨 Showcase of AI-Generated Designs")
|
| 64 |
-
for
|
| 65 |
-
gr.
|
|
|
|
| 66 |
|
| 67 |
demo.launch()
|
| 68 |
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
import io
|
|
|
|
| 4 |
import os
|
| 5 |
+
import json
|
| 6 |
+
from PIL import Image
|
| 7 |
+
|
| 8 |
+
# Load Hugging Face API Key from Space Secrets
|
| 9 |
HF_API_KEY = os.getenv("HF_TOKEN")
|
| 10 |
API_URL = "https://api-inference.huggingface.co/models/sameedhayat/corgy_dog_LoRA"
|
| 11 |
headers = {"Authorization": f"Bearer {HF_API_KEY}"}
|
|
|
|
| 39 |
return f"Error generating image: {str(e)}"
|
| 40 |
|
| 41 |
def fetch_showcase_images():
|
| 42 |
+
"""Fetch images from the local 'images' directory and use prompts from a JSON file."""
|
| 43 |
+
images_dir = "images"
|
| 44 |
+
json_file = os.path.join(images_dir, "prompts.json")
|
| 45 |
+
showcase_images = []
|
| 46 |
+
|
| 47 |
+
if os.path.exists(json_file):
|
| 48 |
+
with open(json_file, "r") as f:
|
| 49 |
+
image_prompts = json.load(f)
|
| 50 |
+
|
| 51 |
+
for filename, prompt in image_prompts.items():
|
| 52 |
+
image_path = os.path.join(images_dir, filename)
|
| 53 |
+
if os.path.exists(image_path):
|
| 54 |
+
showcase_images.append((image_path, prompt))
|
| 55 |
|
| 56 |
+
return showcase_images
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
def create_interface():
|
| 59 |
showcase_images = fetch_showcase_images()
|
|
|
|
| 69 |
btn.click(generate_image, inputs=user_input, outputs=output_image)
|
| 70 |
|
| 71 |
gr.Markdown("### 🎨 Showcase of AI-Generated Designs")
|
| 72 |
+
for img_path, prompt in showcase_images:
|
| 73 |
+
gr.Markdown(f"**Prompt:** {prompt}")
|
| 74 |
+
gr.Image(value=img_path, show_label=False)
|
| 75 |
|
| 76 |
demo.launch()
|
| 77 |
|
images/image1.jpeg
ADDED
|
images/image2.jpeg
ADDED
|
images/image3.jpeg
ADDED
|
images/image4.jpeg
ADDED
|
images/image5.jpeg
ADDED
|
images/image6.jpeg
ADDED
|
images/image7.jpeg
ADDED
|
images/image8.jpeg
ADDED
|
images/image9.jpeg
ADDED
|
images/prompts.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image1.jpeg": "Super Mario face",
|
| 3 |
+
"image2.jpg": "Ferrari back view",
|
| 4 |
+
"image3.jpeg": "Parrot sitting on a branch",
|
| 5 |
+
"image4.jpeg": "Letter A in floral style",
|
| 6 |
+
"image5.jpeg": "A beautiful butterfly",
|
| 7 |
+
"image6.jpeg": "Monkey in floral pattern style",
|
| 8 |
+
"image7.jpeg": "bicycle in silhouette",
|
| 9 |
+
"image8.jpeg": "BMW logo inside floral pattern",
|
| 10 |
+
"image9.jpeg": "Floral pattern"
|
| 11 |
+
}
|