aakashch0179 commited on
Commit
9f983ee
1 Parent(s): 7cb2f03

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -110,7 +110,6 @@
110
  # st.image(pil_images[0])
111
  # st.success("GIF saved as shark_3d.gif")
112
 
113
-
114
  import streamlit as st
115
  import torch
116
  from diffusers import StableDiffusionPipeline
@@ -120,11 +119,10 @@ import numpy as np
120
 
121
  # Model loading
122
  ckpt_id = "openai/shap-e"
123
- StableDiffusionPipeline.from_pretrained(ckpt_id, torch_dtype=torch.float16, use_auth_token=True).to("cuda")
124
  @st.cache_resource
125
  def load_model():
126
- return StableDiffusionPipeline.from_pretrained(ckpt_id).to("cuda")
127
- pipe = load_model()
128
 
129
  # App Title
130
  st.title("Shark 3D Image Generator")
@@ -140,16 +138,19 @@ def should_resize(image):
140
  return False
141
 
142
  # Generate and Display Images
143
- if st.button("Generate"):
144
- with st.spinner("Generating images..."):
145
- images = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=64).images
146
 
147
  pil_images = []
148
- for image in images:
 
 
149
  if should_resize(image):
150
  image = image.resize((256, 256))
151
  pil_images.append(image)
152
 
153
  gif_path = export_to_gif(pil_images, "shark_3d.gif")
154
- st.image(pil_images[0])
155
  st.success("GIF saved as shark_3d.gif")
 
 
110
  # st.image(pil_images[0])
111
  # st.success("GIF saved as shark_3d.gif")
112
 
 
113
  import streamlit as st
114
  import torch
115
  from diffusers import StableDiffusionPipeline
 
119
 
120
  # Model loading
121
  ckpt_id = "openai/shap-e"
 
122
  @st.cache_resource
123
  def load_model():
124
+ return StableDiffusionPipeline.from_pretrained(ckpt_id, torch_dtype=torch.float16, use_auth_token=True).to("cuda")
125
+ pipe = load_model() # Load the model
126
 
127
  # App Title
128
  st.title("Shark 3D Image Generator")
 
138
  return False
139
 
140
  # Generate and Display Images
141
+ if st.button("Generate"):
142
+ with st.spinner("Generating images..."):
143
+ images = pipe(prompt, guidance_scale=guidance_scale, num_inference_steps=64).images
144
 
145
  pil_images = []
146
+ for image in images:
147
+ # ***Insert image conversion logic here***
148
+
149
  if should_resize(image):
150
  image = image.resize((256, 256))
151
  pil_images.append(image)
152
 
153
  gif_path = export_to_gif(pil_images, "shark_3d.gif")
154
+ st.image(pil_images[0])
155
  st.success("GIF saved as shark_3d.gif")
156
+