yejunliang23 commited on
Commit
fe5d321
Β·
verified Β·
1 Parent(s): 9f0ebe5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -164,12 +164,8 @@ def activate_button() -> gr.Button:
164
  def deactivate_button() -> gr.Button:
165
  return gr.Button(interactive=False)
166
 
 
167
  with gr.Blocks() as demo:
168
- pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
169
- try:
170
- pipeline.preprocess_image(Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8))) # Preload rembg
171
- except:
172
- pass
173
  gr.Markdown("""
174
  ## Image to 3D Asset with [TRELLIS](https://trellis3d.github.io/)
175
  * Upload an image and click "Generate" to create a 3D asset. If the image has alpha channel, it be used as the mask. Otherwise, we use `rembg` to remove the background.
@@ -208,6 +204,7 @@ with gr.Blocks() as demo:
208
  trial_id = gr.Textbox(visible=False)
209
  output_buf = gr.State()
210
 
 
211
 
212
  # Handlers
213
  image_prompt.upload(
@@ -251,17 +248,17 @@ with gr.Blocks() as demo:
251
 
252
  # Launch the Gradio app
253
  if __name__ == "__main__":
254
- #pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
255
- #if torch.cuda.is_available():
256
- # pipeline.cuda()
257
- # print("CUDA is available. Using GPU.")
258
- #else:
259
- # print("CUDA not available. Falling back to CPU.")
260
- #try:
261
- # pipeline.preprocess_image(Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8))) # Preload rembg
262
- #except:
263
- # pass
264
- #print(f"CUDA Available: {torch.cuda.is_available()}")
265
- #print(f"CUDA Version: {torch.version.cuda}")
266
- #print(f"Number of GPUs: {torch.cuda.device_count()}")
267
  demo.launch(debug=True)
 
164
  def deactivate_button() -> gr.Button:
165
  return gr.Button(interactive=False)
166
 
167
+
168
  with gr.Blocks() as demo:
 
 
 
 
 
169
  gr.Markdown("""
170
  ## Image to 3D Asset with [TRELLIS](https://trellis3d.github.io/)
171
  * Upload an image and click "Generate" to create a 3D asset. If the image has alpha channel, it be used as the mask. Otherwise, we use `rembg` to remove the background.
 
204
  trial_id = gr.Textbox(visible=False)
205
  output_buf = gr.State()
206
 
207
+ # Example images at the bottom of the page
208
 
209
  # Handlers
210
  image_prompt.upload(
 
248
 
249
  # Launch the Gradio app
250
  if __name__ == "__main__":
251
+ pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
252
+ if torch.cuda.is_available():
253
+ pipeline.cuda()
254
+ print("CUDA is available. Using GPU.")
255
+ else:
256
+ print("CUDA not available. Falling back to CPU.")
257
+ try:
258
+ pipeline.preprocess_image(Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8))) # Preload rembg
259
+ except:
260
+ pass
261
+ print(f"CUDA Available: {torch.cuda.is_available()}")
262
+ print(f"CUDA Version: {torch.version.cuda}")
263
+ print(f"Number of GPUs: {torch.cuda.device_count()}")
264
  demo.launch(debug=True)