Spaces:
Build error
Build error
soupstick
commited on
Commit
Β·
f96d29c
1
Parent(s):
a276f46
Fix: Remove conflicting gradio-client version constraint
Browse files- app.py +58 -54
- requirements.txt +1 -1
app.py
CHANGED
@@ -134,64 +134,68 @@ def format_example_output():
|
|
134 |
return json.dumps(example, indent=2)
|
135 |
|
136 |
# Gradio Interface
|
137 |
-
|
138 |
-
gr.
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
with gr.Row():
|
147 |
-
with gr.Column():
|
148 |
-
image_input = gr.Image(
|
149 |
-
type="pil",
|
150 |
-
label="πΈ Upload Product Image",
|
151 |
-
height=300
|
152 |
-
)
|
153 |
-
prompt_input = gr.Textbox(
|
154 |
-
label="π Instruction (Optional)",
|
155 |
-
value="Generate Amazon listing.",
|
156 |
-
placeholder="Enter custom instruction or use default",
|
157 |
-
lines=2
|
158 |
-
)
|
159 |
-
generate_btn = gr.Button(
|
160 |
-
"π Generate Listing",
|
161 |
-
variant="primary",
|
162 |
-
size="lg"
|
163 |
-
)
|
164 |
|
165 |
-
with gr.
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
)
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
label="Example JSON Structure"
|
178 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
|
180 |
-
|
181 |
-
generate_btn.click(
|
182 |
-
fn=generate_listing,
|
183 |
-
inputs=[image_input, prompt_input],
|
184 |
-
outputs=output_text
|
185 |
-
)
|
186 |
-
|
187 |
-
# Footer
|
188 |
-
gr.Markdown("""
|
189 |
-
---
|
190 |
-
**β οΈ Note**: This demo runs on CPU which may take 1-2 minutes per generation.
|
191 |
-
For faster inference, consider upgrading to GPU hardware.
|
192 |
-
|
193 |
-
**π Links**: [Model Card](https://huggingface.co/soupstick/qwen2vl-amazon-ft-lora) | [Base Model](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct)
|
194 |
-
""")
|
195 |
|
196 |
if __name__ == "__main__":
|
|
|
197 |
demo.launch(share=True)
|
|
|
134 |
return json.dumps(example, indent=2)
|
135 |
|
136 |
# Gradio Interface
|
137 |
+
def create_interface():
|
138 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="Amazon Listing Generator") as demo:
|
139 |
+
gr.Markdown("""
|
140 |
+
# π Qwen2-VL Amazon Listing Generator (LoRA)
|
141 |
+
|
142 |
+
Upload a product image and generate an Amazon-style listing with title, bullet points, description, keywords, and category.
|
143 |
+
|
144 |
+
**Model**: [soupstick/qwen2vl-amazon-ft-lora](https://huggingface.co/soupstick/qwen2vl-amazon-ft-lora) (Qwen2-VL-7B + LoRA)
|
145 |
+
""")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
+
with gr.Row():
|
148 |
+
with gr.Column():
|
149 |
+
image_input = gr.Image(
|
150 |
+
type="pil",
|
151 |
+
label="πΈ Upload Product Image",
|
152 |
+
height=300
|
153 |
+
)
|
154 |
+
prompt_input = gr.Textbox(
|
155 |
+
label="π Instruction (Optional)",
|
156 |
+
value="Generate Amazon listing.",
|
157 |
+
placeholder="Enter custom instruction or use default",
|
158 |
+
lines=2
|
159 |
+
)
|
160 |
+
generate_btn = gr.Button(
|
161 |
+
"π Generate Listing",
|
162 |
+
variant="primary",
|
163 |
+
size="lg"
|
164 |
+
)
|
165 |
+
|
166 |
+
with gr.Column():
|
167 |
+
output_text = gr.Textbox(
|
168 |
+
label="π Generated Listing",
|
169 |
+
lines=15,
|
170 |
+
placeholder="Upload an image and click 'Generate Listing' to see results..."
|
171 |
+
)
|
172 |
+
|
173 |
+
# Example section
|
174 |
+
with gr.Accordion("π Expected Output Format", open=False):
|
175 |
+
gr.Code(
|
176 |
+
format_example_output(),
|
177 |
+
language="json",
|
178 |
+
label="Example JSON Structure"
|
179 |
)
|
180 |
+
|
181 |
+
# Event handler
|
182 |
+
generate_btn.click(
|
183 |
+
fn=generate_listing,
|
184 |
+
inputs=[image_input, prompt_input],
|
185 |
+
outputs=output_text
|
|
|
186 |
)
|
187 |
+
|
188 |
+
# Footer
|
189 |
+
gr.Markdown("""
|
190 |
+
---
|
191 |
+
**β οΈ Note**: This demo runs on CPU which may take 1-2 minutes per generation.
|
192 |
+
For faster inference, consider upgrading to GPU hardware.
|
193 |
+
|
194 |
+
**π Links**: [Model Card](https://huggingface.co/soupstick/qwen2vl-amazon-ft-lora) | [Base Model](https://huggingface.co/Qwen/Qwen2-VL-7B-Instruct)
|
195 |
+
""")
|
196 |
|
197 |
+
return demo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
if __name__ == "__main__":
|
200 |
+
demo = create_interface()
|
201 |
demo.launch(share=True)
|
requirements.txt
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
transformers>=4.44.0
|
2 |
peft>=0.10.0
|
3 |
accelerate>=0.24.0
|
4 |
-
gradio
|
5 |
torch>=2.0.0
|
6 |
torchvision>=0.15.0
|
7 |
Pillow>=9.0.0
|
|
|
1 |
transformers>=4.44.0
|
2 |
peft>=0.10.0
|
3 |
accelerate>=0.24.0
|
4 |
+
gradio==4.44.0
|
5 |
torch>=2.0.0
|
6 |
torchvision>=0.15.0
|
7 |
Pillow>=9.0.0
|