aakashch0179 commited on
Commit
89e3069
1 Parent(s): f3b84cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -15
app.py CHANGED
@@ -52,23 +52,13 @@ ckpt_id = "openai/shap-e"
52
 
53
  @st.cache_resource # Caches the model for faster subsequent runs
54
  def process_image_for_pil(image):
55
- """Converts image data into a format compatible with PIL.Image.fromarray()"""
56
 
57
- # Example 1: If image is already a PIL Image
58
- if isinstance(image, Image.Image):
59
- return image
60
-
61
- # Example 2: If image is a NumPy array
62
- if isinstance(image, np.ndarray):
63
- return Image.fromarray(image)
64
-
65
- # Example 3: If image is a PyTorch Tensor
66
- if isinstance(image, torch.Tensor):
67
- return Image.fromarray(image.detach().cpu().numpy())
68
-
69
- # Add more cases based on the output of print(type(images[0]))
70
 
71
- raise TypeError("Unsupported image format. Please provide conversion logic.")
72
 
73
 
74
  def should_resize():
 
52
 
53
  @st.cache_resource # Caches the model for faster subsequent runs
54
  def process_image_for_pil(image):
55
+ """Converts image data into a format compatible with PIL.Image.fromarray()"""
56
 
57
+ if isinstance(image, np.ndarray): # Assuming NumPy array
58
+ return Image.fromarray(image)
59
+ else:
60
+ raise TypeError("Unsupported image format. Please provide conversion logic.")
 
 
 
 
 
 
 
 
 
61
 
 
62
 
63
 
64
  def should_resize():