Spaces:
Runtime error
Runtime error
File size: 1,050 Bytes
9e83947 5930504 9e83947 53e96bd 746cb43 53e96bd 746cb43 53e96bd 746cb43 53e96bd 746cb43 5930504 53e96bd 5930504 9e83947 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import streamlit as st
from PIL import Image
import torch
from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation
from diffusers import StableDiffusionInpaintPipeline
device = 'cuda' if torch.cuda.is_available() else 'cpu'
seg_processor = AutoImageProcessor.from_pretrained("facebook/mask2former-swin-base-coco-panoptic")
seg_model = Mask2FormerForUniversalSegmentation.from_pretrained("facebook/mask2former-swin-base-coco-panoptic")
# get Stable Diffusion model for image inpainting
pipe = StableDiffusionInpaintPipeline.from_pretrained(
"runwayml/stable-diffusion-inpainting",
torch_dtype=torch.float16,
).to(device)
st.title("Stable Edit - Edit your photos with Stable Diffusion!")
# upload image
filename = st.file_uploader("upload an image")
image = Image.open(filename)
st.image(image)
# Select Area to edit
selection = st.selectbox("Select Area(s) to edit", ("AutoSegment Area", "Draw Custom Area", "Suprise Me"))
# TEMP - DEMO stuff
x = st.slider('Select a value')
st.write(x, 'squared is', x * x)
|