Spaces:
Runtime error
Runtime error
Spinners and Columns
Browse files
app.py
CHANGED
@@ -7,26 +7,36 @@ processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-larg
|
|
7 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")
|
8 |
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
|
9 |
|
10 |
-
|
11 |
|
12 |
with st.sidebar:
|
13 |
image_gen_guidance = st.slider("Stable Diffusion: Guidance Scale", value=7.5)
|
14 |
image_gen_steps = st.slider("stable Diffusion: Inference Steps", value=50)
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
-
|
29 |
-
description = ' '.join(descs)
|
30 |
-
images = pipe(description, guidance_scale=image_gen_guidance, num_inference_steps=image_gen_steps).images
|
31 |
-
for image in images:
|
32 |
st.image(image, caption=description)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-large")
|
8 |
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
|
9 |
|
10 |
+
captions = []
|
11 |
|
12 |
with st.sidebar:
|
13 |
image_gen_guidance = st.slider("Stable Diffusion: Guidance Scale", value=7.5)
|
14 |
image_gen_steps = st.slider("stable Diffusion: Inference Steps", value=50)
|
15 |
|
16 |
+
col1, col2 = st.columns(2)
|
17 |
|
18 |
+
with col1:
|
19 |
+
files = st.file_uploader("Upload images to blend", accept_multiple_files=True)
|
20 |
|
21 |
+
for file_name in files:
|
22 |
+
image = Image.open(file_name)
|
23 |
|
24 |
+
with st.spinner('Captioning Provided Image'):
|
25 |
+
inputs = processor(image, return_tensors="pt")
|
26 |
+
out = model.generate(**inputs)
|
27 |
+
description = processor.decode(out[0], skip_special_tokens=True)
|
28 |
+
captions.append(description)
|
29 |
|
30 |
+
st.success("Image Captioned")
|
|
|
|
|
|
|
31 |
st.image(image, caption=description)
|
32 |
+
|
33 |
+
with col2:
|
34 |
+
if len(captions) > 0:
|
35 |
+
description = ' '.join(captions)
|
36 |
+
|
37 |
+
with st.spinner('Generating Photo from Caption'):
|
38 |
+
images = pipe(description, guidance_scale=image_gen_guidance, num_inference_steps=image_gen_steps).images
|
39 |
+
|
40 |
+
st.success("Image Generated")
|
41 |
+
for image in images:
|
42 |
+
st.image(image, caption=description)
|