Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,14 +10,36 @@ from gradio_client import Client, handle_file
|
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
-
def
|
| 14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 15 |
"""A tool that uses the HuggingFace Space "frogleo/Image-to-3D" to transform a 2D image into a 3D model
|
| 16 |
Args:
|
| 17 |
-
|
| 18 |
-
|
| 19 |
"""
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
@tool
|
| 23 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
@@ -56,7 +78,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 56 |
|
| 57 |
agent = CodeAgent(
|
| 58 |
model=model,
|
| 59 |
-
tools=[final_answer], ## add your tools here (don't remove final answer)
|
| 60 |
max_steps=6,
|
| 61 |
verbosity_level=1,
|
| 62 |
grammar=None,
|
|
|
|
| 10 |
|
| 11 |
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 12 |
@tool
|
| 13 |
+
def image_to_3d(image_path:str)-> dict: #it's import to specify the return type
|
| 14 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
| 15 |
"""A tool that uses the HuggingFace Space "frogleo/Image-to-3D" to transform a 2D image into a 3D model
|
| 16 |
Args:
|
| 17 |
+
image_path: A string with the path to the 2D image that will be used
|
| 18 |
+
|
| 19 |
"""
|
| 20 |
+
|
| 21 |
+
client = Client("frogleo/Image-to-3D")
|
| 22 |
+
result = client.predict(
|
| 23 |
+
image=image_path,
|
| 24 |
+
steps=5,
|
| 25 |
+
guidance_scale=5.5,
|
| 26 |
+
seed=1234,
|
| 27 |
+
octree_resolution=256,
|
| 28 |
+
num_chunks=8000,
|
| 29 |
+
target_face_num=10000,
|
| 30 |
+
randomize_seed=True,
|
| 31 |
+
api_name="/gen_shape"
|
| 32 |
+
)
|
| 33 |
+
print(result)
|
| 34 |
+
|
| 35 |
+
return {
|
| 36 |
+
"glb_path": result[2],
|
| 37 |
+
"obj_path": result[3],
|
| 38 |
+
"file_export": result[1],
|
| 39 |
+
"html_preview": result[0]
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
|
| 44 |
@tool
|
| 45 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
|
| 78 |
|
| 79 |
agent = CodeAgent(
|
| 80 |
model=model,
|
| 81 |
+
tools=[final_answer, image_to_3d], ## add your tools here (don't remove final answer)
|
| 82 |
max_steps=6,
|
| 83 |
verbosity_level=1,
|
| 84 |
grammar=None,
|