Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
|
@@ -1,22 +1,22 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
|
| 22 |
st.title("Stable Edit - Edit your photos with Stable Diffusion!")
|
|
@@ -27,7 +27,7 @@ image = Image.open(filename)
|
|
| 27 |
st.image(image)
|
| 28 |
|
| 29 |
# Select Area to edit
|
| 30 |
-
st.selectbox("
|
| 31 |
|
| 32 |
# TEMP - DEMO stuff
|
| 33 |
x = st.slider('Select a value')
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
|
| 4 |
+
import torch
|
| 5 |
+
from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation
|
| 6 |
+
from diffusers import StableDiffusionInpaintPipeline
|
| 7 |
|
| 8 |
|
| 9 |
+
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
| 10 |
|
| 11 |
+
seg_processor = AutoImageProcessor.from_pretrained("facebook/mask2former-swin-base-coco-panoptic")
|
| 12 |
+
seg_model = Mask2FormerForUniversalSegmentation.from_pretrained("facebook/mask2former-swin-base-coco-panoptic")
|
| 13 |
|
| 14 |
|
| 15 |
+
# get Stable Diffusion model for image inpainting
|
| 16 |
+
pipe = StableDiffusionInpaintPipeline.from_pretrained(
|
| 17 |
+
"runwayml/stable-diffusion-inpainting",
|
| 18 |
+
torch_dtype=torch.float16,
|
| 19 |
+
).to(device)
|
| 20 |
|
| 21 |
|
| 22 |
st.title("Stable Edit - Edit your photos with Stable Diffusion!")
|
|
|
|
| 27 |
st.image(image)
|
| 28 |
|
| 29 |
# Select Area to edit
|
| 30 |
+
selection = st.selectbox("Select Area(s) to edit", ("AutoSegment Area", "Draw Custom Area", "Suprise Me"))
|
| 31 |
|
| 32 |
# TEMP - DEMO stuff
|
| 33 |
x = st.slider('Select a value')
|