aakashch0179 commited on
Commit
a6fe570
1 Parent(s): a24834f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -19
app.py CHANGED
@@ -68,22 +68,17 @@ if st.button("Generate"):
68
  with st.spinner("Generating images..."):
69
  images = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=64).images
70
 
71
- def process_image_data(image_data):
72
- # Assume image_data has a nested structure or is a custom object
73
- # Extract the raw pixel data and reshape as needed
74
- # Example:
75
- if isinstance(image_data, torch.Tensor):
76
- return image_data.numpy()
77
- # ... handle other potential data structures
78
-
79
- # ... (Inside your generation loop)
80
- pil_images = []
81
- for image in images:
82
- processed_data = process_image_data(image)
83
- pil_image = Image.fromarray(processed_data)
84
- resized_image = pil_image.resize((256, 256))
85
- pil_images.append(resized_image)
86
-
87
- gif_path = export_to_gif(pil_images, "shark_3d.gif")
88
- st.image(pil_images[0])
89
- st.success("GIF saved as shark_3d.gif")
 
68
  with st.spinner("Generating images..."):
69
  images = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=64).images
70
 
71
+ # Process images for PIL conversion (This will be customized)
72
+ pil_images = []
73
+ for image in images:
74
+ processed_image = process_image_for_pil(image)
75
+ pil_images.append(processed_image)
76
+
77
+ # Resize Images (Optional)
78
+ if should_resize(): # Add a function to control if resizing is needed
79
+ for i in range(len(pil_images)):
80
+ pil_images[i] = pil_images[i].resize((256, 256))
81
+
82
+ gif_path = export_to_gif(pil_images, "shark_3d.gif")
83
+ st.image(pil_images[0])
84
+ st.success("GIF saved as shark_3d.gif")