Spaces:
Running
on
Zero
Running
on
Zero
ethanweber
commited on
Commit
•
07b9243
1
Parent(s):
02b79da
update
Browse files- app.py +4 -13
- requirements.txt +1 -1
app.py
CHANGED
@@ -61,7 +61,7 @@ def check_input_images(input_images):
|
|
61 |
raise gr.Error("No images uploaded!")
|
62 |
|
63 |
@spaces.GPU(duration=120)
|
64 |
-
def process_images(input_images
|
65 |
|
66 |
images_path = "/tmp/gradio/images"
|
67 |
processed_path = "/tmp/gradio/processed"
|
@@ -81,15 +81,8 @@ def process_images(input_images, compute_segment_anything):
|
|
81 |
download_cmd = "tnd-download-data sam --save-dir /tmp/gradio"
|
82 |
os.system(download_cmd)
|
83 |
|
84 |
-
if compute_segment_anything:
|
85 |
-
sam_cmd = " --compute-segment-anything"
|
86 |
-
else:
|
87 |
-
sam_cmd = " --no-compute-segment-anything"
|
88 |
-
|
89 |
# process the data
|
90 |
process_data_cmd = f"tnd-process-data initialize --dataset toon3d-dataset --input_path {images_path} --data_prefix {processed_path} --sam_checkpoint_prefix /tmp/gradio/sam-checkpoints"
|
91 |
-
process_data_cmd += sam_cmd
|
92 |
-
print(process_data_cmd)
|
93 |
os.system(process_data_cmd)
|
94 |
|
95 |
zip_folder = "/tmp/gradio/processed/toon3d-dataset"
|
@@ -240,9 +233,7 @@ with gr.Blocks(title="Toon3D") as demo:
|
|
240 |
gr.Markdown(_HEADER_)
|
241 |
with gr.Row(variant="panel"):
|
242 |
input_images = gr.File(label="Upload Images", file_count="multiple", file_types=[".jpg", "jpeg", "png"])
|
243 |
-
|
244 |
-
compute_segment_anything = gr.Checkbox(label="Compute Segment Anything? (slow)", value=False)
|
245 |
-
process_data_button = gr.Button("Process Data", elem_id="process_data_button", variant="primary")
|
246 |
processed_data_zip = gr.File(label="Processed Data", file_count="single", file_types=[".zip"], interactive=True)
|
247 |
with gr.Row(variant="panel"):
|
248 |
labeler_visible = gr.Checkbox(label="Show Labeler", value=False)
|
@@ -260,7 +251,7 @@ with gr.Blocks(title="Toon3D") as demo:
|
|
260 |
|
261 |
process_data_button.click(fn=check_input_images, inputs=[input_images]).success(
|
262 |
fn=process_images,
|
263 |
-
inputs=[input_images
|
264 |
outputs=[processed_data_zip],
|
265 |
)
|
266 |
|
@@ -278,4 +269,4 @@ with gr.Blocks(title="Toon3D") as demo:
|
|
278 |
|
279 |
if __name__ == "__main__":
|
280 |
demo.queue(max_size=10)
|
281 |
-
demo.launch()
|
|
|
61 |
raise gr.Error("No images uploaded!")
|
62 |
|
63 |
@spaces.GPU(duration=120)
|
64 |
+
def process_images(input_images):
|
65 |
|
66 |
images_path = "/tmp/gradio/images"
|
67 |
processed_path = "/tmp/gradio/processed"
|
|
|
81 |
download_cmd = "tnd-download-data sam --save-dir /tmp/gradio"
|
82 |
os.system(download_cmd)
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
# process the data
|
85 |
process_data_cmd = f"tnd-process-data initialize --dataset toon3d-dataset --input_path {images_path} --data_prefix {processed_path} --sam_checkpoint_prefix /tmp/gradio/sam-checkpoints"
|
|
|
|
|
86 |
os.system(process_data_cmd)
|
87 |
|
88 |
zip_folder = "/tmp/gradio/processed/toon3d-dataset"
|
|
|
233 |
gr.Markdown(_HEADER_)
|
234 |
with gr.Row(variant="panel"):
|
235 |
input_images = gr.File(label="Upload Images", file_count="multiple", file_types=[".jpg", "jpeg", "png"])
|
236 |
+
process_data_button = gr.Button("Process Data", elem_id="process_data_button", variant="primary")
|
|
|
|
|
237 |
processed_data_zip = gr.File(label="Processed Data", file_count="single", file_types=[".zip"], interactive=True)
|
238 |
with gr.Row(variant="panel"):
|
239 |
labeler_visible = gr.Checkbox(label="Show Labeler", value=False)
|
|
|
251 |
|
252 |
process_data_button.click(fn=check_input_images, inputs=[input_images]).success(
|
253 |
fn=process_images,
|
254 |
+
inputs=[input_images],
|
255 |
outputs=[processed_data_zip],
|
256 |
)
|
257 |
|
|
|
269 |
|
270 |
if __name__ == "__main__":
|
271 |
demo.queue(max_size=10)
|
272 |
+
demo.launch(share=True)
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
toon3d==0.0.
|
2 |
segment_anything @ git+https://github.com/facebookresearch/segment-anything.git
|
|
|
1 |
+
toon3d==0.0.4
|
2 |
segment_anything @ git+https://github.com/facebookresearch/segment-anything.git
|