Spaces:
Runtime error
Runtime error
Commit
·
ec1c2f8
1
Parent(s):
7b4e1fd
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,7 @@ import gradio as gr
|
|
| 3 |
import random
|
| 4 |
import pickle
|
| 5 |
import numpy as np
|
|
|
|
| 6 |
from PIL import Image
|
| 7 |
from huggingface_hub import hf_hub_download
|
| 8 |
|
|
@@ -15,6 +16,17 @@ def pose_generation(scene, count):
|
|
| 15 |
images = [Image.fromarray(results[scene][random.randint(0, 19)]) for i in range(count)]
|
| 16 |
return images
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
def path_planning(case_id):
|
| 19 |
assert isinstance(case_id, str)
|
| 20 |
results_path = hf_hub_download('SceneDiffuser/SceneDiffuser', 'results/path_planning/results.pkl')
|
|
@@ -54,7 +66,17 @@ with gr.Blocks() as demo:
|
|
| 54 |
|
| 55 |
## grasp generation
|
| 56 |
with gr.Tab("Grasp Generation"):
|
| 57 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
## path planning
|
| 60 |
with gr.Tab("Path Planing"):
|
|
|
|
| 3 |
import random
|
| 4 |
import pickle
|
| 5 |
import numpy as np
|
| 6 |
+
import zipfile
|
| 7 |
from PIL import Image
|
| 8 |
from huggingface_hub import hf_hub_download
|
| 9 |
|
|
|
|
| 16 |
images = [Image.fromarray(results[scene][random.randint(0, 19)]) for i in range(count)]
|
| 17 |
return images
|
| 18 |
|
| 19 |
+
def grasp_generation(case_id):
|
| 20 |
+
assert isinstance(case_id, str)
|
| 21 |
+
res = f"./results/grasp_generation/results/{case_id}/{random.randint(0, 19)}.glb"
|
| 22 |
+
if not os.path.exists(res):
|
| 23 |
+
results_path = hf_hub_download('SceneDiffuser/SceneDiffuser', 'results/grasp_generation/results.zip')
|
| 24 |
+
os.makedirs('./results/grasp_generation/', exist_ok=True)
|
| 25 |
+
with zipfile.ZipFile(results_path, 'r') as zip_ref:
|
| 26 |
+
zip_ref.extractall('./results/grasp_generation/')
|
| 27 |
+
|
| 28 |
+
return res
|
| 29 |
+
|
| 30 |
def path_planning(case_id):
|
| 31 |
assert isinstance(case_id, str)
|
| 32 |
results_path = hf_hub_download('SceneDiffuser/SceneDiffuser', 'results/path_planning/results.pkl')
|
|
|
|
| 66 |
|
| 67 |
## grasp generation
|
| 68 |
with gr.Tab("Grasp Generation"):
|
| 69 |
+
with gr.Row():
|
| 70 |
+
with gr.Column():
|
| 71 |
+
input3 = [
|
| 72 |
+
gr.Dropdown(choices=['contactdb+apple', 'contactdb+camera', 'contactdb+cylinder_medium', 'contactdb+door_knob', 'contactdb+rubber_duck', 'contactdb+water_bottle', 'ycb+baseball', 'ycb+pear', 'ycb+potted_meat_can', 'ycb+tomato_soup_can'], label='Objects')
|
| 73 |
+
]
|
| 74 |
+
button3 = gr.Button("Run")
|
| 75 |
+
with gr.Column():
|
| 76 |
+
output3 = [
|
| 77 |
+
gr.Model3D(clear_color=[255, 255, 255, 255], label="Result")
|
| 78 |
+
]
|
| 79 |
+
button3.click(grasp_generation, inputs=input3, outputs=output3)
|
| 80 |
|
| 81 |
## path planning
|
| 82 |
with gr.Tab("Path Planing"):
|