byeongjun-park commited on
Commit
6a6386c
1 Parent(s): 7355d35

HarmonyView update

Browse files
.idea/workspace.xml CHANGED
@@ -7,6 +7,8 @@
7
  <list default="true" id="a993d736-6297-4164-9c29-6b2ab1055a96" name="변경" comment="HarmonyView update">
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
  <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
 
 
10
  </list>
11
  <option name="SHOW_DIALOG" value="false" />
12
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -33,11 +35,12 @@
33
  "RunOnceActivity.OpenProjectViewOnStart": "true",
34
  "RunOnceActivity.ShowReadmeOnStart": "true",
35
  "git-widget-placeholder": "main",
36
- "last_opened_file_path": "/home/byeongjun/HarmonyView"
37
  }
38
  }]]></component>
39
  <component name="RecentsManager">
40
  <key name="CopyFile.RECENT_KEYS">
 
41
  <recent name="$PROJECT_DIR$" />
42
  </key>
43
  </component>
@@ -60,7 +63,7 @@
60
  <workItem from="1703224127800" duration="3023000" />
61
  <workItem from="1703644898438" duration="448000" />
62
  <workItem from="1703677779702" duration="730000" />
63
- <workItem from="1703731914758" duration="9751000" />
64
  </task>
65
  <task id="LOCAL-00001" summary="error resolve">
66
  <option name="closed" value="true" />
@@ -190,7 +193,47 @@
190
  <option name="project" value="LOCAL" />
191
  <updated>1703745776443</updated>
192
  </task>
193
- <option name="localTasksCounter" value="17" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  <servers />
195
  </component>
196
  <component name="Vcs.Log.Tabs.Properties">
 
7
  <list default="true" id="a993d736-6297-4164-9c29-6b2ab1055a96" name="변경" comment="HarmonyView update">
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
  <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/hf_demo/examples/dragon.png" beforeDir="false" afterPath="$PROJECT_DIR$/hf_demo/examples/dragon.png" afterDir="false" />
11
+ <change beforePath="$PROJECT_DIR$/hf_demo/examples/table.png" beforeDir="false" afterPath="$PROJECT_DIR$/hf_demo/examples/table.png" afterDir="false" />
12
  </list>
13
  <option name="SHOW_DIALOG" value="false" />
14
  <option name="HIGHLIGHT_CONFLICTS" value="true" />
 
35
  "RunOnceActivity.OpenProjectViewOnStart": "true",
36
  "RunOnceActivity.ShowReadmeOnStart": "true",
37
  "git-widget-placeholder": "main",
38
+ "last_opened_file_path": "/home/byeongjun/HarmonyView/hf_demo/examples"
39
  }
40
  }]]></component>
41
  <component name="RecentsManager">
42
  <key name="CopyFile.RECENT_KEYS">
43
+ <recent name="$PROJECT_DIR$/hf_demo/examples" />
44
  <recent name="$PROJECT_DIR$" />
45
  </key>
46
  </component>
 
63
  <workItem from="1703224127800" duration="3023000" />
64
  <workItem from="1703644898438" duration="448000" />
65
  <workItem from="1703677779702" duration="730000" />
66
+ <workItem from="1703731914758" duration="15263000" />
67
  </task>
68
  <task id="LOCAL-00001" summary="error resolve">
69
  <option name="closed" value="true" />
 
193
  <option name="project" value="LOCAL" />
194
  <updated>1703745776443</updated>
195
  </task>
196
+ <task id="LOCAL-00017" summary="HarmonyView update">
197
+ <option name="closed" value="true" />
198
+ <created>1703746393808</created>
199
+ <option name="number" value="00017" />
200
+ <option name="presentableId" value="LOCAL-00017" />
201
+ <option name="project" value="LOCAL" />
202
+ <updated>1703746393808</updated>
203
+ </task>
204
+ <task id="LOCAL-00018" summary="HarmonyView update">
205
+ <option name="closed" value="true" />
206
+ <created>1703746440353</created>
207
+ <option name="number" value="00018" />
208
+ <option name="presentableId" value="LOCAL-00018" />
209
+ <option name="project" value="LOCAL" />
210
+ <updated>1703746440353</updated>
211
+ </task>
212
+ <task id="LOCAL-00019" summary="HarmonyView update">
213
+ <option name="closed" value="true" />
214
+ <created>1703746476272</created>
215
+ <option name="number" value="00019" />
216
+ <option name="presentableId" value="LOCAL-00019" />
217
+ <option name="project" value="LOCAL" />
218
+ <updated>1703746476272</updated>
219
+ </task>
220
+ <task id="LOCAL-00020" summary="HarmonyView update">
221
+ <option name="closed" value="true" />
222
+ <created>1703746593511</created>
223
+ <option name="number" value="00020" />
224
+ <option name="presentableId" value="LOCAL-00020" />
225
+ <option name="project" value="LOCAL" />
226
+ <updated>1703746593511</updated>
227
+ </task>
228
+ <task id="LOCAL-00021" summary="HarmonyView update">
229
+ <option name="closed" value="true" />
230
+ <created>1703750375287</created>
231
+ <option name="number" value="00021" />
232
+ <option name="presentableId" value="LOCAL-00021" />
233
+ <option name="project" value="LOCAL" />
234
+ <updated>1703750375287</updated>
235
+ </task>
236
+ <option name="localTasksCounter" value="22" />
237
  <servers />
238
  </component>
239
  <component name="Vcs.Log.Tabs.Properties">
app.py CHANGED
@@ -61,7 +61,13 @@ class BackgroundRemoval:
61
  return image
62
 
63
  def resize_inputs(original_image, sam_image, crop_size, background_removal):
64
- image_input = original_image if background_removal == "Input image" else sam_image
 
 
 
 
 
 
65
  if image_input is None: return None
66
  alpha_np = np.asarray(image_input)[:, :, 3]
67
  coords = np.stack(np.nonzero(alpha_np), 1)[:, (1, 0)]
@@ -190,7 +196,7 @@ def run_demo():
190
  image_block = gr.Image(type='pil', image_mode='RGBA', height=256, label='Input image', tool=None, interactive=True)
191
  elevation = gr.Slider(-10, 40, 30, step=5, label='Elevation angle', interactive=True)
192
  crop_size = gr.Slider(120, 240, 200, step=10, label='Crop size', interactive=True)
193
- background_removal = gr.Radio(["Input image", "SAM output"], value=["SAM output"], label="Input to HarmonyView", info="Which image do you want for the input to HarmonyView?")
194
 
195
  # Compose demo layout & data flow.
196
  with gr.Blocks(title=_TITLE, css="hf_demo/style.css") as demo:
@@ -234,7 +240,9 @@ def run_demo():
234
 
235
  output_block = gr.Image(type='pil', image_mode='RGB', label="Outputs of HarmonyView", height=256, interactive=False)
236
 
237
- image_block.change(fn=partial(sam_predict, mask_predictor, removal), inputs=[image_block], outputs=[sam_block], queue=True)
 
 
238
  background_removal.change(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
239
  crop_size.change(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
240
 
 
61
  return image
62
 
63
  def resize_inputs(original_image, sam_image, crop_size, background_removal):
64
+ if background_removal == "Input image":
65
+ image_input = original_image
66
+ elif background_removal == "SAM output":
67
+ image_input = sam_image
68
+ else:
69
+ return None
70
+
71
  if image_input is None: return None
72
  alpha_np = np.asarray(image_input)[:, :, 3]
73
  coords = np.stack(np.nonzero(alpha_np), 1)[:, (1, 0)]
 
196
  image_block = gr.Image(type='pil', image_mode='RGBA', height=256, label='Input image', tool=None, interactive=True)
197
  elevation = gr.Slider(-10, 40, 30, step=5, label='Elevation angle', interactive=True)
198
  crop_size = gr.Slider(120, 240, 200, step=10, label='Crop size', interactive=True)
199
+ background_removal = gr.Radio(["Input image", "SAM output"], label="Input to HarmonyView", info="Which image do you want for the input to HarmonyView?")
200
 
201
  # Compose demo layout & data flow.
202
  with gr.Blocks(title=_TITLE, css="hf_demo/style.css") as demo:
 
240
 
241
  output_block = gr.Image(type='pil', image_mode='RGB', label="Outputs of HarmonyView", height=256, interactive=False)
242
 
243
+ image_block.change(fn=partial(sam_predict, mask_predictor, removal), inputs=[image_block], outputs=[sam_block], queue=True) \
244
+ .success(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
245
+
246
  background_removal.change(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
247
  crop_size.change(fn=resize_inputs, inputs=[image_block, sam_block, crop_size, background_removal], outputs=[input_block], queue=True)
248
 
hf_demo/examples/dragon.png CHANGED

Git LFS Details

  • SHA256: 2fe2feb6397ef4e5dec71c0cd823337cf071f1720295e9add1a07be167f774f8
  • Pointer size: 132 Bytes
  • Size of remote file: 1.52 MB

Git LFS Details

  • SHA256: a16dbd433a7af533831e4ec81c2b60783c268f6790b7a10a6a2f643c729f499f
  • Pointer size: 131 Bytes
  • Size of remote file: 116 kB
hf_demo/examples/table.png CHANGED

Git LFS Details

  • SHA256: 88de449626b15ecbc0dd68813a4d6a16e077dfb36175c4acc8e3097b8dac569f
  • Pointer size: 132 Bytes
  • Size of remote file: 1.89 MB

Git LFS Details

  • SHA256: 6a66c3304e2f5d06678d3e9dc74e85db9b62089be659d3dbd98fa03bb781b358
  • Pointer size: 131 Bytes
  • Size of remote file: 134 kB