JasonYinnnn commited on
Commit
ae91f05
·
1 Parent(s): 0428eff

update fastapi to 0.112.2

Browse files
Files changed (2) hide show
  1. app.py +4 -54
  2. requirements.txt +2 -2
app.py CHANGED
@@ -74,52 +74,6 @@ import shutil
74
  import time
75
  from concurrent.futures import ThreadPoolExecutor
76
 
77
- # debug
78
- import gradio, gradio_client, pydantic, httpx, fastapi, starlette, jinja2
79
- print("gradio:", gradio.__version__)
80
- print("gradio_client:", gradio_client.__version__)
81
- print("pydantic:", pydantic.__version__)
82
- print("httpx:", httpx.__version__)
83
- print("fastapi:", fastapi.__version__)
84
- print("starlette:", starlette.__version__)
85
- print("jinja2:", jinja2.__version__)
86
-
87
- # # fix bug
88
- # # --- Patch 1: gradio_client schema bool bug ---
89
- # try:
90
- # import gradio_client.utils as _gcu
91
-
92
- # _orig_schema_fn = _gcu._json_schema_to_python_type
93
-
94
- # def _safe_schema_fn(schema, defs=None):
95
- # if not isinstance(schema, dict):
96
- # return "Any"
97
- # return _orig_schema_fn(schema, defs)
98
-
99
- # _gcu._json_schema_to_python_type = _safe_schema_fn
100
- # print("Applied gradio_client schema patch")
101
- # except Exception as e:
102
- # print(f"gradio_client schema patch failed: {e}")
103
-
104
-
105
- # # --- Patch 2: jinja2 cache unhashable dict bug ---
106
- # try:
107
- # from jinja2.utils import LRUCache as _LRUCache
108
-
109
- # _orig_lru_get = _LRUCache.get
110
-
111
- # def _safe_lru_get(self, key, default=None):
112
- # try:
113
- # return _orig_lru_get(self, key, default)
114
- # except TypeError:
115
- # return default
116
-
117
- # _LRUCache.get = _safe_lru_get
118
- # print("Applied jinja2 LRUCache patch")
119
- # except Exception as e:
120
- # print(f"jinja2 LRUCache patch failed: {e}")
121
-
122
-
123
  MARKDOWN = """
124
  ## Image to 3D Scene with [3D-Fixer](https://zx-yin.github.io/3dfixer/)
125
  1. Upload an image, and draw bounding boxes for each instance by holding and dragging the mouse. Then click "Run Segmentation" to generate the segmentation result.
@@ -139,13 +93,13 @@ generated_object_map = {}
139
 
140
  # Prepare models
141
  ## Grounding SAM
142
- sam2_predictor = None # SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large")
143
 
144
  ############## 3D-Fixer model
145
  model_dir = 'HorizonRobotics/3D-Fixer'
146
- # pipeline = ThreeDFixerPipeline.from_pretrained(
147
- # model_dir, compile=False
148
- # )
149
  ############## 3D-Fixer model
150
 
151
  rot = np.array([
@@ -263,10 +217,6 @@ def run_segmentation(
263
  rgb_image = image_prompts["image"].convert("RGB")
264
 
265
  global work_space
266
- global sam2_predictor
267
- if sam2_predictor is None:
268
- # lazy initialization
269
- sam2_predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large")
270
 
271
  # pre-process the layers and get the xyxy boxes of each layer
272
  if len(image_prompts["points"]) == 0:
 
74
  import time
75
  from concurrent.futures import ThreadPoolExecutor
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  MARKDOWN = """
78
  ## Image to 3D Scene with [3D-Fixer](https://zx-yin.github.io/3dfixer/)
79
  1. Upload an image, and draw bounding boxes for each instance by holding and dragging the mouse. Then click "Run Segmentation" to generate the segmentation result.
 
93
 
94
  # Prepare models
95
  ## Grounding SAM
96
+ sam2_predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large", device=torch.device("cpu"))
97
 
98
  ############## 3D-Fixer model
99
  model_dir = 'HorizonRobotics/3D-Fixer'
100
+ pipeline = ThreeDFixerPipeline.from_pretrained(
101
+ model_dir, compile=False
102
+ )
103
  ############## 3D-Fixer model
104
 
105
  rot = np.array([
 
217
  rgb_image = image_prompts["image"].convert("RGB")
218
 
219
  global work_space
 
 
 
 
220
 
221
  # pre-process the layers and get the xyxy boxes of each layer
222
  if len(image_prompts["points"]) == 0:
requirements.txt CHANGED
@@ -34,6 +34,6 @@ spconv-cu118
34
  huggingface_hub==0.36.0
35
  git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
36
  gradio_client==1.3.0
37
- httpx==0.24.1
38
  pydantic==2.10.6
39
- fastapi==0.111.0
 
34
  huggingface_hub==0.36.0
35
  git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
36
  gradio_client==1.3.0
37
+ httpx==0.23.3
38
  pydantic==2.10.6
39
+ fastapi==0.112.2