|
import argparse |
|
import binascii |
|
import glob |
|
import os |
|
import os.path |
|
import numpy as np |
|
import matplotlib.pyplot as plt |
|
import random |
|
import sys |
|
import tempfile |
|
import time |
|
import torch |
|
from PIL import Image |
|
from diffusers import StableDiffusionPipeline |
|
|
|
import gradio as gr |
|
|
|
import artist_lib |
|
|
|
from dotenv import load_dotenv |
|
load_dotenv() |
|
SERVER_NAME = os.getenv("SERVER_NAME") |
|
|
|
drawdemo = gr.Interface( |
|
fn=artist_lib.draw, |
|
inputs=[ |
|
gr.Text(label="Drawing description text", value="hindu mandala neon orange and blue"), |
|
gr.Dropdown(label='Model', choices=["stable-diffusion-2", "stable-diffusion-2-1", "stable-diffusion-v1-5"], value="stable-diffusion-v1-5"), |
|
gr.Checkbox(label="Force-New"), |
|
], |
|
outputs="image", |
|
examples=[ |
|
['hindu mandala fruit salad', "stable-diffusion-v1-5", False] |
|
], |
|
) |
|
|
|
with gr.Blocks() as gallerydemo: |
|
with gr.Column(variant="panel"): |
|
with gr.Row(variant="compact"): |
|
text = gr.Textbox( |
|
label="Enter your prompt", |
|
show_label=False, |
|
max_lines=1, |
|
placeholder="Enter your prompt" |
|
) |
|
btn = gr.Button("Generate image") |
|
|
|
gallery = gr.Gallery( |
|
label="Generated images", show_label=False, elem_id="gallery" |
|
) |
|
|
|
btn.click(artist_lib.fake_gan, None, gallery) |
|
|
|
artist = gr.TabbedInterface( [drawdemo], ["Draw"]) |
|
|
|
artist.queue( |
|
max_size = 4 |
|
) |
|
artist.launch() |
|
|