Update app.py
Browse files
app.py
CHANGED
@@ -57,15 +57,7 @@ def generate_caption_and_image(image):
|
|
57 |
|
58 |
|
59 |
|
60 |
-
|
61 |
-
fabrics = ['cotton', 'silk', 'denim', 'linen', 'polyester', 'wool', 'velvet']
|
62 |
-
patterns = ['striped', 'floral', 'geometric', 'abstract', 'solid', 'polka dots']
|
63 |
-
textile_designs = ['woven texture', 'embroidery', 'printed fabric', 'hand-dyed', 'quilting']
|
64 |
-
|
65 |
-
# Randomly select one from each category
|
66 |
-
selected_fabric = random.choice(fabrics)
|
67 |
-
selected_pattern = random.choice(patterns)
|
68 |
-
selected_textile_design = random.choice(textile_designs)
|
69 |
text = "a picture of "
|
70 |
inputs = processor(img, text, return_tensors="pt").to(device)
|
71 |
|
@@ -97,9 +89,21 @@ def generate_caption_and_image(image):
|
|
97 |
# Gradio UI
|
98 |
iface = gr.Interface(
|
99 |
fn=generate_caption_and_image,
|
100 |
-
inputs=gr.Image(type="pil", label="Upload Image"),
|
|
|
|
|
|
|
|
|
101 |
outputs=[gr.Textbox(label="Generated Caption"), gr.Image(label="Generated Design")],
|
102 |
live=True
|
103 |
)
|
104 |
iface.launch(share=True)
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
|
59 |
|
60 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
text = "a picture of "
|
62 |
inputs = processor(img, text, return_tensors="pt").to(device)
|
63 |
|
|
|
89 |
# Gradio UI
|
90 |
iface = gr.Interface(
|
91 |
fn=generate_caption_and_image,
|
92 |
+
inputs=[gr.Image(type="pil", label="Upload Image"),
|
93 |
+
gr.Radio(fabrics, label="Select Fabric"),
|
94 |
+
gr.Radio(patterns, label="Select Pattern"),
|
95 |
+
gr.Radio(textile_designs, label="Select Textile Design")]
|
96 |
+
|
97 |
outputs=[gr.Textbox(label="Generated Caption"), gr.Image(label="Generated Design")],
|
98 |
live=True
|
99 |
)
|
100 |
iface.launch(share=True)
|
101 |
|
102 |
+
|
103 |
+
|
104 |
+
fabrics = ['cotton', 'silk', 'denim', 'linen', 'polyester', 'wool', 'velvet']
|
105 |
+
patterns = ['striped', 'floral', 'geometric', 'abstract', 'solid', 'polka dots']
|
106 |
+
textile_designs = ['woven texture', 'embroidery', 'printed fabric', 'hand-dyed', 'quilting']
|
107 |
+
|
108 |
+
|
109 |
+
|