Wootang01's picture
Create app.py
022e492
raw
history blame
No virus
964 Bytes
import gradio as gr
import diffusers
import streamlit as st
device = "cpu"
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", revision = "fp16", use_auth_token = st.secrets["USER_TOKEN"])
pipe = pipe.to("cpu")
from PIL import Image
import torch
def StableDiffusionPipeline (prompt, Guide, iSteps, seed):
generator = torch.Generator("cpu").manual_seed(seed)
image = pipe(prompt, num_inference_steps = iSteps, guidence_scale = Guide).images[0]
return image
iface = gr.Interface(fn = StableDiffusionPipeline, inputs = [
gr.Textbox(label = 'Prompt Input Text'),
gr.Slider(2, 15, value = 7, label = 'Guidence Scale'),
gr.Slider(10, 100, value = 25, step = 1, label = 'Number of Iterations'),
gr.Slider(
label = "Seed",
minimum = 0,
maximum = 2147483647,
step = 1,
randomize = True)
],
outputs = 'image')
iface.launch()