Spaces:
Sleeping
Sleeping
File size: 2,336 Bytes
44ee4e3 9c2f138 44ee4e3 f4489df 44ee4e3 f4489df 44ee4e3 f4489df 2c2bd10 f4489df 44ee4e3 c374e9f 8255c42 44ee4e3 3084e8d e8fa7da 3084e8d 9286c34 3084e8d 67148f6 44ee4e3 67148f6 44ee4e3 94088a8 ccd9bce c740754 67148f6 2c2bd10 67148f6 44ee4e3 007df00 44ee4e3 3084e8d 44ee4e3 9286c34 44ee4e3 3084e8d 44ee4e3 9286c34 44ee4e3 |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
import streamlit as st
import cv2 as cv
import time
import torch
from diffusers import StableDiffusionPipeline
def create_model(loc = "stabilityai/stable-diffusion-2-1-base", mch = 'cpu'):
pipe = StableDiffusionPipeline.from_pretrained(loc)
pipe = pipe.to(mch)
return pipe
# t2i = st.title("""
# Txt2Img
# ###### `CLICK "Create_Update_Model"` :
# - `FIRST RUN OF THE CODE`
# - `CHANGING MODEL`""")
# the_type = st.selectbox("Model",("stabilityai/stable-diffusion-2-1-base",
# "CompVis/stable-diffusion-v1-4"))
# create = st.button("Create The Model")
# if create:
# st.session_state.t2m_mod = create_model(loc=the_type)
the_type = "stabilityai/stable-diffusion-2-1-base"
st.session_state.t2m_mod = create_model(loc=the_type)
prom = st.text_input("Prompt",'')
neg_prom = st.text_input("Negative Prompt",'')
style = st.selectbox("TODO: Image Style",("Cyberpunk",
"Picasso",
"Real-world specific",
"Digital Art",
"Aesthetics"))
c1,c2,c3,c6 = st.columns([1,1,1,1])
c8 = st.columns([1,1,1,1])
c4,c5 = st.columns(2)
with c1:
bu_1 = st.text_input("Seed",'666')
with c2:
bu_2 = st.text_input("Steps",'12')
with c3:
bu_3 = st.text_input("Number of Images",'1')
with c6:
bu_6 = st.text_input("Guidance Scale",'7.5')
with c4:
sl_1 = st.slider("Width",128,1024,512,8)
with c5:
sl_2 = st.slider("hight",128,1024,512,8)
st.session_state.generator = torch.Generator("cpu").manual_seed(int(bu_1))
create = st.button("Imagine")
if create:
model = st.session_state.t2m_mod
generator = st.session_state.generator
if int(bu_3) == 1 :
IMG = model(prom, negative_prompt = neg_prom, width=int(sl_1), height=int(sl_2),
num_inference_steps=int(bu_2),
guidance_scale = float(bu_6),
generator=generator).images[0]
st.image(IMG)
else :
PROMS = [prom]*int(bu_3)
IMGS = model(PROMS, negative_prompt = neg_prom, width=int(sl_1), height=int(sl_2),
num_inference_steps=int(bu_2),
guidance_scale = float(bu_6),
generator=generator).images
st.image(IMGS) |