Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,17 @@
|
|
1 |
-
import
|
2 |
from PIL import Image
|
3 |
import gradio as gr
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Trigger word for model
|
8 |
trigger_word = "T shirt design, TshirtDesignAF, "
|
@@ -19,32 +28,25 @@ def generate_image(dress_type, fabric_type, color_type, design):
|
|
19 |
full_prompt = f"{base_description} {trigger_word}"
|
20 |
print("Generating image with:", full_prompt)
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
"
|
25 |
-
|
|
|
26 |
)
|
|
|
27 |
|
28 |
-
# Decode the returned image
|
29 |
-
if result and "image" in result:
|
30 |
-
image_data = result["image"].split(",")[1]
|
31 |
-
image = Image.open(BytesIO(base64.b64decode(image_data)))
|
32 |
-
return image
|
33 |
-
else:
|
34 |
-
raise RuntimeError("Image generation failed or response was invalid.")
|
35 |
-
|
36 |
-
# Gradio interface
|
37 |
iface = gr.Interface(
|
38 |
fn=generate_image,
|
39 |
inputs=[
|
40 |
-
gr.Textbox(label="Dress Type"
|
41 |
-
gr.Textbox(label="Fabric Type"
|
42 |
-
gr.Textbox(label="Color Type"
|
43 |
-
gr.Textbox(label="Design"
|
44 |
],
|
45 |
outputs="image",
|
46 |
title="TShirt Design XL Image Generator",
|
47 |
-
description="Powered by Redmond.AI — Generate stunning T-shirt designs from simple attributes
|
48 |
)
|
49 |
|
50 |
print("Launching Gradio interface...")
|
|
|
1 |
+
from huggingface_hub import InferenceClient
|
2 |
from PIL import Image
|
3 |
import gradio as gr
|
4 |
+
import os
|
5 |
+
|
6 |
+
# Load token from environment
|
7 |
+
token = os.environ["HF_TOKEN"]
|
8 |
+
|
9 |
+
# Create the client
|
10 |
+
client = InferenceClient(
|
11 |
+
model="artificialguybr/TshirtDesignRedmond-V2",
|
12 |
+
provider="fal-ai",
|
13 |
+
token=token,
|
14 |
+
)
|
15 |
|
16 |
# Trigger word for model
|
17 |
trigger_word = "T shirt design, TshirtDesignAF, "
|
|
|
28 |
full_prompt = f"{base_description} {trigger_word}"
|
29 |
print("Generating image with:", full_prompt)
|
30 |
|
31 |
+
image = client.text_to_image(
|
32 |
+
prompt=full_prompt,
|
33 |
+
negative_prompt="(worst quality, low quality, lowres, bad photo, ...)",
|
34 |
+
num_inference_steps=30,
|
35 |
+
guidance_scale=7.5,
|
36 |
)
|
37 |
+
return image
|
38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
iface = gr.Interface(
|
40 |
fn=generate_image,
|
41 |
inputs=[
|
42 |
+
gr.Textbox(label="Dress Type"),
|
43 |
+
gr.Textbox(label="Fabric Type"),
|
44 |
+
gr.Textbox(label="Color Type"),
|
45 |
+
gr.Textbox(label="Design"),
|
46 |
],
|
47 |
outputs="image",
|
48 |
title="TShirt Design XL Image Generator",
|
49 |
+
description="Powered by Redmond.AI — Generate stunning T-shirt designs from simple attributes.",
|
50 |
)
|
51 |
|
52 |
print("Launching Gradio interface...")
|