aakashch0179 commited on
Commit
738b266
1 Parent(s): ced6f74

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -47,6 +47,7 @@ from diffusers import ShapEPipeline
47
  from diffusers.utils import export_to_gif
48
  from PIL import Image
49
  import numpy as np
 
50
 
51
  # Model loading (Ideally done once at the start for efficiency)
52
  ckpt_id = "openai/shap-e"
@@ -54,8 +55,13 @@ ckpt_id = "openai/shap-e"
54
  @st.cache_resource # Caches the model for faster subsequent runs
55
  def process_image_for_pil(image):
56
  if isinstance(image, torch.Tensor):
57
- image_array = image.detach().cpu().numpy()
58
- return Image.fromarray(image_array)
 
 
 
 
 
59
  else:
60
  raise TypeError("Unsupported image format. Please provide conversion logic.")
61
 
 
47
  from diffusers.utils import export_to_gif
48
  from PIL import Image
49
  import numpy as np
50
+ import PyTorch
51
 
52
  # Model loading (Ideally done once at the start for efficiency)
53
  ckpt_id = "openai/shap-e"
 
55
  @st.cache_resource # Caches the model for faster subsequent runs
56
  def process_image_for_pil(image):
57
  if isinstance(image, torch.Tensor):
58
+ # Your existing PyTorch conversion
59
+ elif isinstance(image, np.ndarray):
60
+ # Your existing Numpy conversion
61
+ elif isinstance(image, list): # Assuming a nested list structure
62
+ flattened_data = [pixel for sublist in image for pixel in sublist]
63
+ image_array = np.array(flattened_data).reshape(256, 256, 3) # Hypothetical reshape
64
+ return Image.fromarray(image_array)
65
  else:
66
  raise TypeError("Unsupported image format. Please provide conversion logic.")
67