thekarthikeyansekar
commited on
Commit
•
38cbc62
1
Parent(s):
5194753
Create requirements.txt
Browse files- requirements.txt +49 -0
requirements.txt
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from PIL import Image
|
3 |
+
import torch
|
4 |
+
from diffusers import AutoPipelineForInpainting
|
5 |
+
from diffusers.utils import load_image
|
6 |
+
|
7 |
+
pipe = AutoPipelineForInpainting.from_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1", torch_dtype=torch.float16, variant="fp16")
|
8 |
+
generator = torch.Generator(device="cuda").manual_seed(0)
|
9 |
+
|
10 |
+
def main():
|
11 |
+
st.title("Image and Text Preview App")
|
12 |
+
|
13 |
+
# Upload images
|
14 |
+
st.sidebar.subheader("Upload Images")
|
15 |
+
uploaded_image1 = st.sidebarfile_uploader("Upload Image", type=["jpg", "jpeg", "png"])
|
16 |
+
uploaded_image2 = st.sidebarfile_uploader("Upload Mask", type=["jpg", "jpeg", "png"])
|
17 |
+
|
18 |
+
# Input text
|
19 |
+
st.subheader("Text Prompts")
|
20 |
+
prompt = st.text_input("Text prompt", "")
|
21 |
+
negative_prompt = st.text_input("Negative prompt", "")
|
22 |
+
|
23 |
+
guidance_scale = st.text_input("Guidance scale", 7.5)
|
24 |
+
steps = st.text_input("Steps", 20)
|
25 |
+
strength = st.text_input("Strength", 1)
|
26 |
+
|
27 |
+
btn_submit = st.button("Generate")
|
28 |
+
|
29 |
+
if btn_submit:
|
30 |
+
init_image = Image.open(uploaded_image1).convert("RGB")
|
31 |
+
st.image(init_image, caption="Uploaded Image", use_column_width=True)
|
32 |
+
mask_image = Image.open(uploaded_image2).convert("RGB")
|
33 |
+
st.image(mask_image, caption="Uploaded Mask", use_column_width=True)
|
34 |
+
|
35 |
+
output = pipe(prompt = prompt,
|
36 |
+
negative_prompt=negative_prompt,
|
37 |
+
image=init_image,
|
38 |
+
mask_image=mask_image,
|
39 |
+
guidance_scale=int(guidance_scale),
|
40 |
+
num_inference_steps=int(steps),
|
41 |
+
strength=strength,
|
42 |
+
generator=generator)
|
43 |
+
|
44 |
+
st.text("Generated Image:")
|
45 |
+
st.image(output.images[0])
|
46 |
+
|
47 |
+
|
48 |
+
if __name__ == "__main__":
|
49 |
+
main()
|