ysharma HF Staff commited on
Commit
c8a7168
·
verified ·
1 Parent(s): b884545

Rename; keep only generated-subject examples

Browse files
Files changed (3) hide show
  1. README.md +6 -6
  2. app.py +13 -48
  3. examples/examples.json +0 -192
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: Qwen-Image 2.1 Camera Control
3
  emoji: 🔄
4
  colorFrom: indigo
5
  colorTo: pink
@@ -11,7 +11,7 @@ startup_duration_timeout: 1h
11
  short_description: Rotate the camera around a transparent object
12
  license: other
13
  models:
14
- - ML-Intern-lab/Qwen-Image-2.1-camera-control
15
  - Qwen/Qwen-Image-2.1
16
  datasets:
17
  - ML-Intern-lab/gso-orbit-rgba
@@ -22,15 +22,15 @@ tags:
22
  - rgba
23
  ---
24
 
25
- # Qwen-Image 2.1 Camera Control
26
 
27
- Test bench for [ML-Intern-lab/Qwen-Image-2.1-camera-control](https://huggingface.co/ML-Intern-lab/Qwen-Image-2.1-camera-control),
28
  a camera-orbit LoRA for [Qwen-Image 2.1](https://huggingface.co/Qwen/Qwen-Image-2.1) trained with ML Intern in HuggingChat on
29
  [ML-Intern-lab/gso-orbit-rgba](https://huggingface.co/datasets/ML-Intern-lab/gso-orbit-rgba).
30
 
31
  Upload one transparent PNG, pick a rotation (45 to 180 degrees, relative to the uploaded view) and an elevation, and get the same object
32
- from the new viewpoint with transparency preserved. Held-out examples show the ground-truth render and the measured metrics for that pair;
33
- a checkbox runs the base model on the same prompt and seed for comparison; the turntable button chains seven views into a GIF.
34
 
35
  Non-commercial research demo. The base model and adapter are under the Qwen Research License. **Built with Qwen.**
36
  Training renders are from Google Scanned Objects (CC-BY 4.0).
 
1
  ---
2
+ title: Qwen-Image 2.1 Viewpoint Orbit LoRA
3
  emoji: 🔄
4
  colorFrom: indigo
5
  colorTo: pink
 
11
  short_description: Rotate the camera around a transparent object
12
  license: other
13
  models:
14
+ - ML-Intern-lab/Qwen-Image-2.1-viewpoint-orbit-LoRA
15
  - Qwen/Qwen-Image-2.1
16
  datasets:
17
  - ML-Intern-lab/gso-orbit-rgba
 
22
  - rgba
23
  ---
24
 
25
+ # Qwen-Image 2.1 Viewpoint Orbit LoRA
26
 
27
+ Demo for [ML-Intern-lab/Qwen-Image-2.1-viewpoint-orbit-LoRA](https://huggingface.co/ML-Intern-lab/Qwen-Image-2.1-viewpoint-orbit-LoRA),
28
  a camera-orbit LoRA for [Qwen-Image 2.1](https://huggingface.co/Qwen/Qwen-Image-2.1) trained with ML Intern in HuggingChat on
29
  [ML-Intern-lab/gso-orbit-rgba](https://huggingface.co/datasets/ML-Intern-lab/gso-orbit-rgba).
30
 
31
  Upload one transparent PNG, pick a rotation (45 to 180 degrees, relative to the uploaded view) and an elevation, and get the same object
32
+ from the new viewpoint with transparency preserved. A checkbox runs the base model on the same prompt and seed for comparison;
33
+ the turntable button chains seven views into a GIF.
34
 
35
  Non-commercial research demo. The base model and adapter are under the Qwen Research License. **Built with Qwen.**
36
  Training renders are from Google Scanned Objects (CC-BY 4.0).
app.py CHANGED
@@ -12,7 +12,7 @@ from huggingface_hub import hf_hub_download
12
  from PIL import Image
13
 
14
  BASE_ID = "Qwen/Qwen-Image-2.1"
15
- LORA_ID = "ML-Intern-lab/Qwen-Image-2.1-camera-control"
16
  LORA_FILE = "checkpoints/steps2000res768/orbit_alpha_lora_gate_up_split.safetensors" # diffusers-keyed file
17
  DATASET_ID = "ML-Intern-lab/gso-orbit-rgba"
18
  SIZE = 768
@@ -31,7 +31,6 @@ pipe.load_lora_weights(hf_hub_download(LORA_ID, LORA_FILE), adapter_name="orbit"
31
 
32
  with open(os.path.join(EX_DIR, "examples.json"), encoding="utf-8") as f:
33
  EXAMPLES = json.load(f)
34
- HELDOUT = [e for e in EXAMPLES if e["kind"] == "heldout"]
35
  OOD = [e for e in EXAMPLES if e["kind"] == "ood"]
36
 
37
 
@@ -142,7 +141,7 @@ CSS = """
142
  """
143
 
144
  INTRO = f"""
145
- # 🔄 Qwen-Image 2.1 Camera Control
146
  Give it **one transparent PNG** of an object and a camera move. It returns the same object from the new viewpoint, **still transparent**.
147
  Rotation is relative to the view you upload; elevation is absolute.
148
 
@@ -151,9 +150,8 @@ LoRA: [{LORA_ID}](https://huggingface.co/{LORA_ID}) on [Qwen-Image 2.1](https://
151
  """
152
 
153
  ABOUT = """
154
- **Two kinds of examples.** *Held-out objects* are real scanned objects the LoRA never saw; each shows the **ground-truth render** of the requested
155
- view next to the model's output, plus the metrics ML Intern measured for that exact pair. *Generated subjects* are the out-of-domain set from the
156
- model card: there is no ground truth, so judge them by eye.
157
 
158
  **Compare with base model** runs the same prompt and seed with the LoRA switched off, so you can see what the adapter adds. On the 160-edit
159
  held-out test the LoRA scored alpha IoU 0.794 against 0.731 for the base model, and LPIPS 0.090 against 0.099.
@@ -165,7 +163,7 @@ which must be invented. Uploaded images should already be transparent; an opaque
165
  90-degree moves are the hardest bucket. Baked-in lighting on generated subjects is sometimes carried into the new view.
166
  """
167
 
168
- with gr.Blocks(title="Qwen-Image 2.1 Camera Control") as demo:
169
  with gr.Column(elem_id="col-container"):
170
  gr.Markdown(INTRO)
171
  with gr.Row(equal_height=False):
@@ -183,12 +181,9 @@ with gr.Blocks(title="Qwen-Image 2.1 Camera Control") as demo:
183
  steps = gr.Slider(8, 50, value=40, step=1, label="Steps", info="40 is how it was evaluated; 20 is a fast preview")
184
  seed = gr.Slider(0, MAX_SEED, value=0, step=1, label="Seed")
185
  randomize = gr.Checkbox(True, label="Randomize seed")
186
- truth_md = gr.Markdown("", elem_id="truth")
187
  with gr.Column(scale=7):
188
  with gr.Row():
189
  result = gr.Image(label="LoRA: new view (RGBA)", format="png", image_mode="RGBA", height=380)
190
- truth = gr.Image(label="Ground truth (held-out examples only)", format="png", image_mode="RGBA",
191
- height=380, visible=False)
192
  base_out = gr.Image(label="Base model, same prompt and seed", format="png", image_mode="RGBA",
193
  height=380, visible=False)
194
  with gr.Row():
@@ -199,19 +194,11 @@ with gr.Blocks(title="Qwen-Image 2.1 Camera Control") as demo:
199
  object_fit="contain")
200
  tt_gif = gr.Image(label="Turntable GIF", height=300)
201
 
202
- gr.Markdown("## Examples")
203
- with gr.Tabs():
204
- with gr.Tab(f"Held-out scanned objects, with ground truth ({len(HELDOUT)})"):
205
- g_held = gr.Gallery(
206
- value=[(os.path.join(EX_DIR, e["source"]), f"{move_label(e['move_deg'], e['side'])}, {e['elevation']}")
207
- for e in HELDOUT],
208
- columns=6, height="auto", allow_preview=False, object_fit="contain", show_label=False,
209
- interactive=False, elem_classes="ex-gallery")
210
- with gr.Tab(f"Generated subjects, no ground truth ({len(OOD)})"):
211
- g_ood = gr.Gallery(
212
- value=[(os.path.join(EX_DIR, e["source"]), e["object_id"].replace("_", " ")) for e in OOD],
213
- columns=6, height="auto", allow_preview=False, object_fit="contain", show_label=False,
214
- interactive=False, elem_classes="ex-gallery")
215
  with gr.Accordion("About, metrics and limitations", open=False):
216
  gr.Markdown(ABOUT)
217
 
@@ -227,33 +214,11 @@ with gr.Blocks(title="Qwen-Image 2.1 Camera Control") as demo:
227
 
228
  compare_base.change(show_base, compare_base, base_out, api_visibility="private")
229
 
230
- def pick_heldout(evt: gr.SelectData):
231
- e = HELDOUT[evt.index]
232
- elev = {"low": "low angle", "eye": "eye level", "high": "elevated"}.get(e["elevation"], e["elevation"])
233
- m = e["metrics"]
234
- md = (f"### Held-out object: {e['object_id'].replace('_', ' ')}\n"
235
- f"Instruction: `{e['instruction']}` \n"
236
- f"ML Intern's measured result for this pair: alpha IoU **{m['alpha_iou']:.3f}**, LPIPS **{m['lpips']:.3f}**, "
237
- f"PSNR **{m['psnr']:.1f}**, DINOv2 **{m['dino_sim']:.3f}**")
238
- return (Image.open(os.path.join(EX_DIR, e["source"])), move_label(e["move_deg"], e["side"]), elev,
239
- gr.update(value=Image.open(os.path.join(EX_DIR, e["truth"])), visible=True), md, False, 0)
240
-
241
- g_held.select(pick_heldout, None, [image, move, elevation, truth, truth_md, randomize, seed],
242
- api_visibility="private").then(orbit, edit_inputs, [result, base_out, prompt_out, seed, note_out],
243
- api_visibility="private")
244
-
245
  def pick_ood(evt: gr.SelectData):
246
- e = OOD[evt.index]
247
- return (Image.open(os.path.join(EX_DIR, e["source"])), gr.update(value=None, visible=False),
248
- f"### Generated subject: {e['object_id'].replace('_', ' ')}\nNo ground truth; judge by eye.")
249
-
250
- g_ood.select(pick_ood, None, [image, truth, truth_md], api_visibility="private").then(
251
- orbit, edit_inputs, [result, base_out, prompt_out, seed, note_out], api_visibility="private")
252
-
253
- def on_upload():
254
- return gr.update(value=None, visible=False), ""
255
 
256
- image.upload(on_upload, None, [truth, truth_md], api_visibility="private")
 
257
 
258
  if __name__ == "__main__":
259
  demo.queue(max_size=20).launch(theme=gr.themes.Citrus(), css=CSS)
 
12
  from PIL import Image
13
 
14
  BASE_ID = "Qwen/Qwen-Image-2.1"
15
+ LORA_ID = "ML-Intern-lab/Qwen-Image-2.1-viewpoint-orbit-LoRA"
16
  LORA_FILE = "checkpoints/steps2000res768/orbit_alpha_lora_gate_up_split.safetensors" # diffusers-keyed file
17
  DATASET_ID = "ML-Intern-lab/gso-orbit-rgba"
18
  SIZE = 768
 
31
 
32
  with open(os.path.join(EX_DIR, "examples.json"), encoding="utf-8") as f:
33
  EXAMPLES = json.load(f)
 
34
  OOD = [e for e in EXAMPLES if e["kind"] == "ood"]
35
 
36
 
 
141
  """
142
 
143
  INTRO = f"""
144
+ # 🔄 Qwen-Image 2.1 Viewpoint Orbit LoRA
145
  Give it **one transparent PNG** of an object and a camera move. It returns the same object from the new viewpoint, **still transparent**.
146
  Rotation is relative to the view you upload; elevation is absolute.
147
 
 
150
  """
151
 
152
  ABOUT = """
153
+ **Examples.** The twelve subjects are the out-of-domain set from the model card, generated with the base model's text-to-image mode.
154
+ They are nothing like the scanned household objects the LoRA trained on, and there is no ground truth, so judge them by eye.
 
155
 
156
  **Compare with base model** runs the same prompt and seed with the LoRA switched off, so you can see what the adapter adds. On the 160-edit
157
  held-out test the LoRA scored alpha IoU 0.794 against 0.731 for the base model, and LPIPS 0.090 against 0.099.
 
163
  90-degree moves are the hardest bucket. Baked-in lighting on generated subjects is sometimes carried into the new view.
164
  """
165
 
166
+ with gr.Blocks(title="Qwen-Image 2.1 Viewpoint Orbit LoRA") as demo:
167
  with gr.Column(elem_id="col-container"):
168
  gr.Markdown(INTRO)
169
  with gr.Row(equal_height=False):
 
181
  steps = gr.Slider(8, 50, value=40, step=1, label="Steps", info="40 is how it was evaluated; 20 is a fast preview")
182
  seed = gr.Slider(0, MAX_SEED, value=0, step=1, label="Seed")
183
  randomize = gr.Checkbox(True, label="Randomize seed")
 
184
  with gr.Column(scale=7):
185
  with gr.Row():
186
  result = gr.Image(label="LoRA: new view (RGBA)", format="png", image_mode="RGBA", height=380)
 
 
187
  base_out = gr.Image(label="Base model, same prompt and seed", format="png", image_mode="RGBA",
188
  height=380, visible=False)
189
  with gr.Row():
 
194
  object_fit="contain")
195
  tt_gif = gr.Image(label="Turntable GIF", height=300)
196
 
197
+ gr.Markdown(f"## Examples ({len(OOD)} generated subjects)\nClick one to load it and run the selected move.")
198
+ g_ood = gr.Gallery(
199
+ value=[(os.path.join(EX_DIR, e["source"]), e["object_id"].replace("_", " ")) for e in OOD],
200
+ columns=6, height="auto", allow_preview=False, object_fit="contain", show_label=False,
201
+ interactive=False, elem_classes="ex-gallery")
 
 
 
 
 
 
 
 
202
  with gr.Accordion("About, metrics and limitations", open=False):
203
  gr.Markdown(ABOUT)
204
 
 
214
 
215
  compare_base.change(show_base, compare_base, base_out, api_visibility="private")
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  def pick_ood(evt: gr.SelectData):
218
+ return Image.open(os.path.join(EX_DIR, OOD[evt.index]["source"]))
 
 
 
 
 
 
 
 
219
 
220
+ g_ood.select(pick_ood, None, image, api_visibility="private").then(
221
+ orbit, edit_inputs, edit_outputs, api_visibility="private")
222
 
223
  if __name__ == "__main__":
224
  demo.queue(max_size=20).launch(theme=gr.themes.Citrus(), css=CSS)
examples/examples.json CHANGED
@@ -1,196 +1,4 @@
1
  [
2
- {
3
- "kind": "heldout",
4
- "object_id": "Nikon_1_AW1_w11275mm_Lens_Silver",
5
- "source": "heldout_Nikon_1_AW1_w11275mm_Lens_Silver_src.png",
6
- "truth": "heldout_Nikon_1_AW1_w11275mm_Lens_Silver_truth.png",
7
- "move_deg": 45,
8
- "side": "right",
9
- "elevation": "low",
10
- "instruction": "<orbit> rotate the camera 45 degrees to the right, low angle",
11
- "metrics": {
12
- "alpha_iou": 0.967,
13
- "lpips": 0.0613,
14
- "psnr": 22.68,
15
- "dino_sim": 0.8816
16
- }
17
- },
18
- {
19
- "kind": "heldout",
20
- "object_id": "30_CONSTRUCTION_SET",
21
- "source": "heldout_30_CONSTRUCTION_SET_src.png",
22
- "truth": "heldout_30_CONSTRUCTION_SET_truth.png",
23
- "move_deg": 45,
24
- "side": "right",
25
- "elevation": "high",
26
- "instruction": "<orbit> rotate the camera 45 degrees to the right, elevated",
27
- "metrics": {
28
- "alpha_iou": 0.5126,
29
- "lpips": 0.1087,
30
- "psnr": 21.22,
31
- "dino_sim": 0.8272
32
- }
33
- },
34
- {
35
- "kind": "heldout",
36
- "object_id": "Hefty_Waste_Basket_Decorative_Bronze_85_liter",
37
- "source": "heldout_Hefty_Waste_Basket_Decorative_Bronze_85_liter_src.png",
38
- "truth": "heldout_Hefty_Waste_Basket_Decorative_Bronze_85_liter_truth.png",
39
- "move_deg": 45,
40
- "side": "left",
41
- "elevation": "low",
42
- "instruction": "<orbit> rotate the camera 45 degrees to the left, low angle",
43
- "metrics": {
44
- "alpha_iou": 0.8308,
45
- "lpips": 0.0494,
46
- "psnr": 23.26,
47
- "dino_sim": 0.8852
48
- }
49
- },
50
- {
51
- "kind": "heldout",
52
- "object_id": "Top_Paw_Dog_Bow_Bone_Ceramic_13_fl_oz_total",
53
- "source": "heldout_Top_Paw_Dog_Bow_Bone_Ceramic_13_fl_oz_total_src.png",
54
- "truth": "heldout_Top_Paw_Dog_Bow_Bone_Ceramic_13_fl_oz_total_truth.png",
55
- "move_deg": 45,
56
- "side": "right",
57
- "elevation": "eye",
58
- "instruction": "<orbit> rotate the camera 45 degrees to the right, eye level",
59
- "metrics": {
60
- "alpha_iou": 0.8465,
61
- "lpips": 0.0864,
62
- "psnr": 19.62,
63
- "dino_sim": 0.8653
64
- }
65
- },
66
- {
67
- "kind": "heldout",
68
- "object_id": "Cole_Hardware_Butter_Dish_Square_Red",
69
- "source": "heldout_Cole_Hardware_Butter_Dish_Square_Red_src.png",
70
- "truth": "heldout_Cole_Hardware_Butter_Dish_Square_Red_truth.png",
71
- "move_deg": 90,
72
- "side": "left",
73
- "elevation": "eye",
74
- "instruction": "<orbit> rotate the camera 90 degrees to the left, eye level",
75
- "metrics": {
76
- "alpha_iou": 0.836,
77
- "lpips": 0.0745,
78
- "psnr": 23.63,
79
- "dino_sim": 0.8206
80
- }
81
- },
82
- {
83
- "kind": "heldout",
84
- "object_id": "Mastic_Gum",
85
- "source": "heldout_Mastic_Gum_src.png",
86
- "truth": "heldout_Mastic_Gum_truth.png",
87
- "move_deg": 45,
88
- "side": "left",
89
- "elevation": "high",
90
- "instruction": "<orbit> rotate the camera 45 degrees to the left, elevated",
91
- "metrics": {
92
- "alpha_iou": 0.8921,
93
- "lpips": 0.0506,
94
- "psnr": 21.73,
95
- "dino_sim": 0.9497
96
- }
97
- },
98
- {
99
- "kind": "heldout",
100
- "object_id": "Olive_Kids_Dinosaur_Land_Pack_n_Snack",
101
- "source": "heldout_Olive_Kids_Dinosaur_Land_Pack_n_Snack_src.png",
102
- "truth": "heldout_Olive_Kids_Dinosaur_Land_Pack_n_Snack_truth.png",
103
- "move_deg": 90,
104
- "side": "right",
105
- "elevation": "high",
106
- "instruction": "<orbit> rotate the camera 90 degrees to the right, elevated",
107
- "metrics": {
108
- "alpha_iou": 0.7243,
109
- "lpips": 0.201,
110
- "psnr": 18.16,
111
- "dino_sim": 0.7668
112
- }
113
- },
114
- {
115
- "kind": "heldout",
116
- "object_id": "Sootheze_Cold_Therapy_Elephant",
117
- "source": "heldout_Sootheze_Cold_Therapy_Elephant_src.png",
118
- "truth": "heldout_Sootheze_Cold_Therapy_Elephant_truth.png",
119
- "move_deg": 90,
120
- "side": "left",
121
- "elevation": "low",
122
- "instruction": "<orbit> rotate the camera 90 degrees to the left, low angle",
123
- "metrics": {
124
- "alpha_iou": 0.6249,
125
- "lpips": 0.0391,
126
- "psnr": 25.77,
127
- "dino_sim": 0.7289
128
- }
129
- },
130
- {
131
- "kind": "heldout",
132
- "object_id": "DPC_Handmade_Hat_Brown",
133
- "source": "heldout_DPC_Handmade_Hat_Brown_src.png",
134
- "truth": "heldout_DPC_Handmade_Hat_Brown_truth.png",
135
- "move_deg": 180,
136
- "side": "",
137
- "elevation": "high",
138
- "instruction": "<orbit> rotate the camera 180 degrees, elevated",
139
- "metrics": {
140
- "alpha_iou": 0.7099,
141
- "lpips": 0.0873,
142
- "psnr": 20.84,
143
- "dino_sim": 0.4568
144
- }
145
- },
146
- {
147
- "kind": "heldout",
148
- "object_id": "TURBOPROP_AIRPLANE_WITH_PILOT",
149
- "source": "heldout_TURBOPROP_AIRPLANE_WITH_PILOT_src.png",
150
- "truth": "heldout_TURBOPROP_AIRPLANE_WITH_PILOT_truth.png",
151
- "move_deg": 180,
152
- "side": "",
153
- "elevation": "eye",
154
- "instruction": "<orbit> rotate the camera 180 degrees, eye level",
155
- "metrics": {
156
- "alpha_iou": 0.8657,
157
- "lpips": 0.0353,
158
- "psnr": 25.09,
159
- "dino_sim": 0.8674
160
- }
161
- },
162
- {
163
- "kind": "heldout",
164
- "object_id": "Crayola_Washable_Sidewalk_Chalk_16_pack",
165
- "source": "heldout_Crayola_Washable_Sidewalk_Chalk_16_pack_src.png",
166
- "truth": "heldout_Crayola_Washable_Sidewalk_Chalk_16_pack_truth.png",
167
- "move_deg": 90,
168
- "side": "right",
169
- "elevation": "eye",
170
- "instruction": "<orbit> rotate the camera 90 degrees to the right, eye level",
171
- "metrics": {
172
- "alpha_iou": 0.8588,
173
- "lpips": 0.1665,
174
- "psnr": 18.85,
175
- "dino_sim": 0.7442
176
- }
177
- },
178
- {
179
- "kind": "heldout",
180
- "object_id": "Perricone_MD_Face_Finishing_Moisturizer_4_oz",
181
- "source": "heldout_Perricone_MD_Face_Finishing_Moisturizer_4_oz_src.png",
182
- "truth": "heldout_Perricone_MD_Face_Finishing_Moisturizer_4_oz_truth.png",
183
- "move_deg": 0,
184
- "side": "",
185
- "elevation": "low",
186
- "instruction": "<orbit> keep the camera angle, low angle",
187
- "metrics": {
188
- "alpha_iou": 0.7424,
189
- "lpips": 0.0869,
190
- "psnr": 26.15,
191
- "dino_sim": 0.7129
192
- }
193
- },
194
  {
195
  "kind": "ood",
196
  "object_id": "cartoon_mascot",
 
1
  [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  {
3
  "kind": "ood",
4
  "object_id": "cartoon_mascot",