Nightfury16 commited on
Commit
66a6b28
Β·
1 Parent(s): 03e1c51
Files changed (1) hide show
  1. app.py +47 -34
app.py CHANGED
@@ -44,11 +44,17 @@ def get_image_inputs(image_file, image_url):
44
  def run_qwen(raw_b64, prompt):
45
  url = f"https://api.runpod.ai/v2/{QWEN_ENDPOINT_ID}/runsync"
46
  headers = {"Content-Type": "application/json", "Authorization": f"Bearer {RUNPOD_API_KEY}"}
47
- payload = {"input": {"image": raw_b64, "prompt": prompt, "seed": 42, "use_lightning": True, "true_guidance_scale": 2.5, "num_inference_steps": 4}}
 
 
 
 
 
48
  try:
49
  response = requests.post(url, headers=headers, json=payload, timeout=60)
50
  return b64_to_pil(response.json()["output"]["images"][0])
51
- except: return None
 
52
 
53
  def run_fal_flux(image_url, prompt):
54
  try:
@@ -56,7 +62,8 @@ def run_fal_flux(image_url, prompt):
56
  result = handler.get()
57
  resp = requests.get(result['images'][0]['url'])
58
  return bytes_to_pil(resp.content)
59
- except: return None
 
60
 
61
  def run_gemini(image_bytes, prompt):
62
  if not gemini_client: return None
@@ -64,11 +71,17 @@ def run_gemini(image_bytes, prompt):
64
  response = gemini_client.models.generate_content(
65
  model="gemini-2.5-flash-image",
66
  contents=[Part.from_bytes(data=image_bytes, mime_type="image/jpeg"), prompt],
67
- config=GenerateContentConfig(response_modalities=["IMAGE"], image_config=ImageConfig(aspect_ratio="16:9"), candidate_count=1),
 
 
 
 
68
  )
69
  for part in response.candidates[0].content.parts:
70
- if part.inline_data: return bytes_to_pil(part.inline_data.data)
71
- except: return None
 
 
72
 
73
  def compare_all(image_file, image_url, prompt):
74
  raw_bytes, raw_b64, web_url = get_image_inputs(image_file, image_url)
@@ -77,46 +90,46 @@ def compare_all(image_file, image_url, prompt):
77
  return
78
 
79
  og_pil = bytes_to_pil(raw_bytes)
80
- q_img, f_img, g_img = None, None, None
81
 
82
- yield og_pil, q_img, f_img, g_img
83
-
84
- q_img = run_qwen(raw_b64, prompt)
85
- yield og_pil, q_img, f_img, g_img
86
-
87
- f_img = run_fal_flux(web_url, prompt)
88
- yield og_pil, q_img, f_img, g_img
89
-
90
- g_img = run_gemini(raw_bytes, prompt)
91
- yield og_pil, q_img, f_img, g_img
92
 
93
  with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 95% !important}") as demo:
94
- gr.Markdown("# πŸ›‹οΈ Interior Design Model Arena")
95
 
96
- with gr.Row(variant="panel"):
97
  with gr.Column(scale=3):
98
- input_prompt = gr.Textbox(label="Design Instructions", value=DEFAULT_PROMPT, lines=3)
99
- with gr.Column(scale=1):
100
- input_file = gr.Image(label="Upload (Fixed Width)", type="filepath", height=120)
101
- with gr.Column(scale=1):
102
- input_url = gr.Textbox(label="Or Image URL", placeholder="http://...")
103
- run_btn = gr.Button("πŸš€ GENERATE ALL", variant="primary", size="lg")
104
 
105
- gr.Separator()
106
 
107
  with gr.Row():
108
  with gr.Column():
109
- gr.Markdown("#### πŸ–ΌοΈ Original")
110
- out_og = gr.Image(show_label=False, type="pil", height=400, show_download_button=False)
 
111
  with gr.Column():
112
- gr.Markdown("#### ⚑ Qwen-Edit\n($0.006 avg)")
113
- out_qwen = gr.Image(show_label=False, type="pil", height=400)
 
114
  with gr.Column():
115
- gr.Markdown("#### 🎨 Flux-2\n($0.03)")
116
- out_fal = gr.Image(show_label=False, type="pil", height=400)
 
117
  with gr.Column():
118
- gr.Markdown("#### πŸ’Ž Gemini 2.5\n($0.039)")
119
- out_gemini = gr.Image(show_label=False, type="pil", height=400)
120
 
121
  run_btn.click(
122
  fn=compare_all,
 
44
  def run_qwen(raw_b64, prompt):
45
  url = f"https://api.runpod.ai/v2/{QWEN_ENDPOINT_ID}/runsync"
46
  headers = {"Content-Type": "application/json", "Authorization": f"Bearer {RUNPOD_API_KEY}"}
47
+ payload = {
48
+ "input": {
49
+ "image": raw_b64, "prompt": prompt, "seed": 42,
50
+ "use_lightning": True, "true_guidance_scale": 2.5, "num_inference_steps": 4
51
+ }
52
+ }
53
  try:
54
  response = requests.post(url, headers=headers, json=payload, timeout=60)
55
  return b64_to_pil(response.json()["output"]["images"][0])
56
+ except:
57
+ return None
58
 
59
  def run_fal_flux(image_url, prompt):
60
  try:
 
62
  result = handler.get()
63
  resp = requests.get(result['images'][0]['url'])
64
  return bytes_to_pil(resp.content)
65
+ except:
66
+ return None
67
 
68
  def run_gemini(image_bytes, prompt):
69
  if not gemini_client: return None
 
71
  response = gemini_client.models.generate_content(
72
  model="gemini-2.5-flash-image",
73
  contents=[Part.from_bytes(data=image_bytes, mime_type="image/jpeg"), prompt],
74
+ config=GenerateContentConfig(
75
+ response_modalities=["IMAGE"],
76
+ image_config=ImageConfig(aspect_ratio="16:9"),
77
+ candidate_count=1,
78
+ ),
79
  )
80
  for part in response.candidates[0].content.parts:
81
+ if part.inline_data:
82
+ return bytes_to_pil(part.inline_data.data)
83
+ except:
84
+ return None
85
 
86
  def compare_all(image_file, image_url, prompt):
87
  raw_bytes, raw_b64, web_url = get_image_inputs(image_file, image_url)
 
90
  return
91
 
92
  og_pil = bytes_to_pil(raw_bytes)
93
+ qwen_img, flux_img, gemini_img = None, None, None
94
 
95
+ yield og_pil, qwen_img, flux_img, gemini_img
96
+ qwen_img = run_qwen(raw_b64, prompt)
97
+ yield og_pil, qwen_img, flux_img, gemini_img
98
+ flux_img = run_fal_flux(web_url, prompt)
99
+ yield og_pil, qwen_img, flux_img, gemini_img
100
+ gemini_img = run_gemini(raw_bytes, prompt)
101
+ yield og_pil, qwen_img, flux_img, gemini_img
 
 
 
102
 
103
  with gr.Blocks(theme=gr.themes.Soft(), css=".gradio-container {max-width: 95% !important}") as demo:
104
+ gr.HTML("<h2 style='text-align: center;'>πŸ›‹οΈ Interior Design Model Arena</h2>")
105
 
106
+ with gr.Row():
107
  with gr.Column(scale=3):
108
+ input_prompt = gr.Textbox(label="Edit Prompt", value=DEFAULT_PROMPT, lines=3)
109
+ with gr.Column(scale=2):
110
+ with gr.Row():
111
+ input_file = gr.Image(label="Upload", type="filepath", height=100)
112
+ input_url = gr.Textbox(label="URL", placeholder="Optional...")
113
+ run_btn = gr.Button("πŸš€ Generate Comparison", variant="primary")
114
 
115
+ gr.HTML("<hr>")
116
 
117
  with gr.Row():
118
  with gr.Column():
119
+ gr.HTML("<div style='text-align: center'><b>ORIGINAL</b><br><small>Source Reference</small></div>")
120
+ out_og = gr.Image(show_label=False, type="pil", height=350, object_fit="contain")
121
+
122
  with gr.Column():
123
+ gr.HTML("<div style='text-align: center'><b>QWEN-EDIT</b><br><small>$0.004 - $0.008</small></div>")
124
+ out_qwen = gr.Image(show_label=False, type="pil", height=350, object_fit="contain")
125
+
126
  with gr.Column():
127
+ gr.HTML("<div style='text-align: center'><b>FLUX-2 EDIT</b><br><small>$0.03</small></div>")
128
+ out_fal = gr.Image(show_label=False, type="pil", height=350, object_fit="contain")
129
+
130
  with gr.Column():
131
+ gr.HTML("<div style='text-align: center'><b>GEMINI 2.5</b><br><small>$0.039</small></div>")
132
+ out_gemini = gr.Image(show_label=False, type="pil", height=350, object_fit="contain")
133
 
134
  run_btn.click(
135
  fn=compare_all,