Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,6 +29,19 @@ upload_file = st.file_uploader('Upload an Image')
|
|
| 29 |
from PIL import Image
|
| 30 |
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if upload_file:
|
| 33 |
test_sample = Image.open(upload_file)
|
| 34 |
|
|
@@ -38,7 +51,6 @@ if upload_file:
|
|
| 38 |
generated_ids = model.generate(pixel_values=pixel_values, max_length=50)
|
| 39 |
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 40 |
|
| 41 |
-
|
| 42 |
for i in range(10):
|
| 43 |
st.write('New Caption is :')
|
| 44 |
st.write(generated_caption)
|
|
|
|
| 29 |
from PIL import Image
|
| 30 |
|
| 31 |
|
| 32 |
+
import torch
|
| 33 |
+
from diffusers import StableDiffusionPipeline
|
| 34 |
+
import time
|
| 35 |
+
t1 = time.time()
|
| 36 |
+
model_id = "CompVis/stable-diffusion-v1-4"
|
| 37 |
+
device = "cuda"
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
| 42 |
+
pipe = pipe.to(device)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
if upload_file:
|
| 46 |
test_sample = Image.open(upload_file)
|
| 47 |
|
|
|
|
| 51 |
generated_ids = model.generate(pixel_values=pixel_values, max_length=50)
|
| 52 |
generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 53 |
|
|
|
|
| 54 |
for i in range(10):
|
| 55 |
st.write('New Caption is :')
|
| 56 |
st.write(generated_caption)
|