soupstick commited on
Commit
f96d29c
Β·
1 Parent(s): a276f46

Fix: Remove conflicting gradio-client version constraint

Browse files
Files changed (2) hide show
  1. app.py +58 -54
  2. 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
- with gr.Blocks(theme=gr.themes.Soft(), title="Amazon Listing Generator") as demo:
138
- gr.Markdown("""
139
- # πŸ›’ Qwen2-VL Amazon Listing Generator (LoRA)
140
-
141
- Upload a product image and generate an Amazon-style listing with title, bullet points, description, keywords, and category.
142
-
143
- **Model**: [soupstick/qwen2vl-amazon-ft-lora](https://huggingface.co/soupstick/qwen2vl-amazon-ft-lora) (Qwen2-VL-7B + LoRA)
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.Column():
166
- output_text = gr.Textbox(
167
- label="πŸ“‹ Generated Listing",
168
- lines=15,
169
- placeholder="Upload an image and click 'Generate Listing' to see results..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  )
171
-
172
- # Example section
173
- with gr.Accordion("πŸ“‹ Expected Output Format", open=False):
174
- gr.Code(
175
- format_example_output(),
176
- language="json",
177
- label="Example JSON Structure"
178
  )
 
 
 
 
 
 
 
 
 
179
 
180
- # Event handler
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>=4.38.0 # or gradio==4.35.0
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