Spaces:
Runtime error
Runtime error
Commit
·
7d311fc
1
Parent(s):
42461cf
Upload 6 files
Browse files- README (11).md +10 -0
- banner.png +0 -0
- fetch (1).py +6 -0
- gitattributes (6).txt +36 -0
- main (1).py +204 -0
- requirements (12).txt +4 -0
README (11).md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Stable Diffusion Demo
|
| 3 |
+
emoji: 🔥
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: red
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 3.42.0
|
| 8 |
+
app_file: main.py
|
| 9 |
+
pinned: true
|
| 10 |
+
---
|
banner.png
ADDED
|
fetch (1).py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
|
| 3 |
+
def get_values():
|
| 4 |
+
resp = {"doc":{"metadata":{"image":[],"title":"","description":""},"api":{"method":"post","url":"","auth":"required","params":[],"results":{"codes":[]},"apiSetting":"63e152abae39c70076448b6f"},"swagger":{"path":"/job"},"next":{"description":"","pages":[]},"algolia":{"recordCount":1,"publishPending":False,"updatedAt":"2023-05-13T20:21:27.923Z"},"title":"Create a generation","icon":"","updates":[],"type":"endpoint","slug":"generate","excerpt":"Use this endpoint to start generating an image on Prodia.","body":"","order":0,"isReference":True,"deprecated":False,"hidden":False,"sync_unique":"generate","link_url":"","link_external":False,"previousSlug":"","slugUpdatedAt":"2023-02-06T19:16:54.830Z","revision":63,"_id":"63e152adae39c70076448b76","category":"63e152abae39c70076448b70","createdAt":"2023-02-06T19:19:09.122Z","updatedAt":"2023-07-05T20:56:55.881Z","parentDoc":"63ea65265e3b33000eda4124","project":"63def422013dd3004536bc06","version":{"version":"1.2","version_clean":"1.2.0","codename":"ImageGenie","is_stable":True,"is_beta":True,"is_hidden":False,"is_deprecated":False,"categories":["63def422013dd3004536bc0d","63def422013dd3004536bc0d","63def422013dd3004536bc0f","63def423013dd3004536bc17","63def4ab8570a300596ffa51","63e14c3d7db7ee005f65368e","63e152095cca0b02d7803f6b","63e1523e0de987044faf7119","63e1525b8f256f045a6ae39b","63e152abae39c70076448b70","63e28c3fb119180074e5a342","63e3c154fff713002b0b4b15","63e3c15ef6c1c5001e00a2a7","64020c652839760066ca3c5b"],"_id":"63def422013dd3004536bc0b","project":"63def422013dd3004536bc06","releaseDate":"2023-02-05T00:11:14.850Z","createdAt":"2023-02-05T00:11:14.850Z","__v":1},"__v":0,"isApi":True,"tutorials":[],"id":"63e152adae39c70076448b76"},"hideTOC":False,"meta":{"description":"Use this endpoint to start generating an image on Prodia.","hidden":False,"title":"Create a generation","type":"reference"},"oasDefinition":{"openapi":"3.0.3","info":{"title":"Prodia API","description":"Welcome to Prodia's API :)","termsOfService":"https://app.prodia.com/#/terms-of-service","contact":{"email":"[email protected]"},"version":"1.2.0"},"servers":[{"url":"https://api.prodia.com/v1"}],"tags":[{"name":"Image Generation","description":"Image Generation API"}],"paths":{"/job":{"post":{"tags":["Image Generation"],"summary":"Create a generation","description":"Use this endpoint to start generating an image on Prodia.","operationId":"generate","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateRequest"}}},"required":True},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Invalid Generation Parameters"},"401":{"description":"Key Not Recognised"},"402":{"description":"API Access Not Enabled"}}}},"/transform":{"post":{"tags":["Image Generation"],"summary":"Transform an existing image","description":"Use this endpoint to do an 'img2img' style generation.","operationId":"transform","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TransformRequest"}}},"required":True},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Invalid Generation Parameters"},"401":{"description":"Key Not Recognised"},"402":{"description":"API Access Not Enabled"}}}},"/controlnet":{"post":{"tags":["Image Generation"],"summary":"[Coming soon] Create a Controlnet generation","description":"Use this endpoint to do a Controlnet generation.","operationId":"controlnet","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ControlNetRequest"}}},"required":True},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"400":{"description":"Invalid Generation Parameters"},"401":{"description":"Key Not Recognised"},"402":{"description":"API Access Not Enabled"}}}},"/job/{jobId}":{"get":{"parameters":[{"in":"path","name":"jobId","schema":{"type":"string"},"required":True,"description":"ID of Job"}],"tags":["Image Generation"],"summary":"Retrieve a generation","description":"Get information about a generation job, including status.","operationId":"getJob","responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"401":{"description":"Key Not Recognised"},"402":{"description":"API Access Not Enabled"}}}}},"components":{"securitySchemes":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"X-Prodia-Key"}},"schemas":{"Model":{"enum":["analog-diffusion-1.0.ckpt [9ca13f02]","anythingv3_0-pruned.ckpt [2700c435]","anything-v4.5-pruned.ckpt [65745d25]","AOM3A3_orangemixs.safetensors [9600da17]","deliberate_v2.safetensors [10ec4b29]","dreamlike-diffusion-1.0.safetensors [5c9fd6e0]","dreamlike-diffusion-2.0.safetensors [fdcf65e7]","dreamshaper_5BakedVae.safetensors [a3fbf318]","dreamshaper_6BakedVae.safetensors [114c8abb]","elldreths-vivid-mix.safetensors [342d9d26]","lyriel_v15.safetensors [65d547c5]","lyriel_v16.safetensors [68fceea2]","mechamix_v10.safetensors [ee685731]","meinamix_meinaV9.safetensors [2ec66ab0]","openjourney_V4.ckpt [ca2f377f]","portrait+1.0.safetensors [1400e684]","Realistic_Vision_V1.4-pruned-fp16.safetensors [8d21810b]","Realistic_Vision_V2.0.safetensors [79587710]","revAnimated_v122.safetensors [3f4fefd9]","riffusion-model-v1.ckpt [3aafa6fe]","sdv1_4.ckpt [7460a6fa]","v1-5-pruned-emaonly.ckpt [81761151]","shoninsBeautiful_v10.safetensors [25d8c546]","theallys-mix-ii-churned.safetensors [5d9225a4]","timeless-1.0.ckpt [7c4971d4]"]},"ControlnetModel":{"enum":["control_v11p_sd15_softedge [a8575a2a]","control_v11p_sd15_mlsd [aca30ff0]","control_v11e_sd15_ip2p [c4bb465c]","control_v11p_sd15_seg [e1f51eb9]","control_v11p_sd15_inpaint [ebff9138]","control_v11p_sd15s2_lineart_anime [3825e83e]","control_v11e_sd15_shuffle [526bfdae]","control_v11p_sd15_canny [d14c016b]","control_v11p_sd15_lineart [43d4be0d]","control_v11p_sd15_normalbae [316696f1]","control_v11f1p_sd15_depth [cfd03158]","control_v11p_sd15_openpose [cab727d4]","control_v11f1e_sd15_tile [a371b31b]","control_v11p_sd15_scribble [d4ba51ff]"]},"Sampler":{"enum":["Euler","Euler a","Heun","DPM++ 2M Karras","DDIM"]},"Job":{"type":"object","properties":{"job":{"type":"string","example":"xxxx-xxxx-xxxx-xxxx","description":"Job ID"},"params":{"type":"object","example":"{}","description":"Job Generation Params"},"status":{"enum":["queued","generating","failed","succeeded"]},"imageUrl":{"type":"string","description":"Direct URL to generated image"}}},"GenerateRequest":{"type":"object","required":["prompt"],"properties":{"model":{"$ref":"#/components/schemas/Model"},"prompt":{"type":"string","example":"puppies in a cloud, 4k","description":"Image Prompt"},"negative_prompt":{"type":"string","example":"badly drawn","description":"Negative Image Prompt"},"steps":{"type":"number","example":25,"description":"Steps"},"cfg_scale":{"type":"number","example":7,"description":"CFG Scale"},"seed":{"type":"number","example":-1,"description":"Seed"},"upscale":{"type":"boolean","example":False,"description":"Enable 2x Upscale"},"sampler":{"$ref":"#/components/schemas/Sampler"},"aspect_ratio":{"enum":["square","portrait","landscape"]}}},"TransformRequest":{"type":"object","required":["prompt","imageUrl"],"properties":{"imageUrl":{"type":"string","example":"https://example.com/image.png","description":"Input Image URL"},"model":{"$ref":"#/components/schemas/Model"},"prompt":{"type":"string","example":"puppies in a cloud, 4k","description":"Image Prompt"},"denoising_strength":{"type":"number","example":0.7,"description":"Strength of image transfomation"},"negative_prompt":{"type":"string","example":"badly drawn","description":"Negative Image Prompt"},"steps":{"type":"number","example":25,"description":"Steps"},"cfg_scale":{"type":"number","example":7,"description":"CFG Scale"},"seed":{"type":"number","example":-1,"description":"Seed"},"upscale":{"type":"boolean","example":False,"description":"Enable 2x Upscale"},"sampler":{"$ref":"#/components/schemas/Sampler"}}},"ControlNetRequest":{"type":"object","required":["prompt","imageUrl"],"properties":{"imageUrl":{"type":"string","example":"https://example.com/image.png","description":"Input Image URL"},"controlnet_model":{"$ref":"#/components/schemas/ControlnetModel"},"prompt":{"type":"string","example":"puppies in a cloud, 4k","description":"Image Prompt"},"negative_prompt":{"type":"string","example":"badly drawn","description":"Negative Image Prompt"},"steps":{"type":"number","example":25,"description":"Steps"},"cfg_scale":{"type":"number","example":7,"description":"CFG Scale"},"seed":{"type":"number","example":-1,"description":"Seed"},"sampler":{"$ref":"#/components/schemas/Sampler"}}}}},"security":[{"ApiKeyAuth":[]}],"x-readme":{"explorer-enabled":True,"proxy-enabled":True,"samples-enabled":True},"_id":"63e152abae39c70076448b6f"},"oasPublicUrl":"@prodia/v1.2#edaualjq791p4","oauth":True,"loginUrl":"https://app.prodia.com/api","suggestedEdits":True}
|
| 5 |
+
return [resp["oasDefinition"]["components"]["schemas"]['Model']['enum'], resp["oasDefinition"]["components"]["schemas"]['Sampler']['enum']]
|
| 6 |
+
|
gitattributes (6).txt
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
image[[:space:]](3).png filter=lfs diff=lfs merge=lfs -text
|
main (1).py
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fetch import get_values
|
| 3 |
+
from dotenv import load_dotenv
|
| 4 |
+
load_dotenv()
|
| 5 |
+
import prodia
|
| 6 |
+
import requests
|
| 7 |
+
import random
|
| 8 |
+
from datetime import datetime
|
| 9 |
+
import os
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
prodia_key = os.getenv('PRODIA_X_KEY', None)
|
| 14 |
+
if prodia_key is None:
|
| 15 |
+
print("Please set PRODIA_X_KEY in .env, closing...")
|
| 16 |
+
exit()
|
| 17 |
+
client = prodia.Client(api_key=prodia_key)
|
| 18 |
+
|
| 19 |
+
def process_input_text2img(prompt, negative_prompt, steps, cfg_scale, number, seed, model, sampler, aspect_ratio, upscale, save=False):
|
| 20 |
+
images = []
|
| 21 |
+
for image in range(number):
|
| 22 |
+
result = client.txt2img(prompt=prompt, negative_prompt=negative_prompt, model=model, sampler=sampler,
|
| 23 |
+
steps=steps, cfg_scale=cfg_scale, seed=seed, aspect_ratio=aspect_ratio, upscale=upscale)
|
| 24 |
+
images.append(result.url)
|
| 25 |
+
if save:
|
| 26 |
+
date = datetime.now()
|
| 27 |
+
if not os.path.isdir(f'./outputs/{date.year}-{date.month}-{date.day}'):
|
| 28 |
+
os.mkdir(f'./outputs/{date.year}-{date.month}-{date.day}')
|
| 29 |
+
img_data = requests.get(result.url).content
|
| 30 |
+
with open(f"./outputs/{date.year}-{date.month}-{date.day}/{random.randint(1, 10000000000000)}_{result.seed}.png", "wb") as f:
|
| 31 |
+
f.write(img_data)
|
| 32 |
+
return images
|
| 33 |
+
|
| 34 |
+
def process_input_img2img(init, prompt, negative_prompt, steps, cfg_scale, number, seed, model, sampler, ds, upscale, save):
|
| 35 |
+
images = []
|
| 36 |
+
for image in range(number):
|
| 37 |
+
result = client.img2img(imageUrl=init, prompt=prompt, negative_prompt=negative_prompt, model=model, sampler=sampler,
|
| 38 |
+
steps=steps, cfg_scale=cfg_scale, seed=seed, denoising_strength=ds, upscale=upscale)
|
| 39 |
+
images.append(result.url)
|
| 40 |
+
if save:
|
| 41 |
+
date = datetime.now()
|
| 42 |
+
if not os.path.isdir(f'./outputs/{date.year}-{date.month}-{date.day}'):
|
| 43 |
+
os.mkdir(f'./outputs/{date.year}-{date.month}-{date.day}')
|
| 44 |
+
img_data = requests.get(result.url).content
|
| 45 |
+
with open(f"./outputs/{date.year}-{date.month}-{date.day}/{random.randint(1, 10000000000000)}_{result.seed}.png", "wb") as f:
|
| 46 |
+
f.write(img_data)
|
| 47 |
+
return images
|
| 48 |
+
|
| 49 |
+
"""
|
| 50 |
+
def process_input_control(init, prompt, negative_prompt, steps, cfg_scale, number, seed, model, control_model, sampler):
|
| 51 |
+
images = []
|
| 52 |
+
for image in range(number):
|
| 53 |
+
result = client.controlnet(imageUrl=init, prompt=prompt, negative_prompt=negative_prompt, model=model, sampler=sampler,
|
| 54 |
+
steps=steps, cfg_scale=cfg_scale, seed=seed, controlnet_model=control_model)
|
| 55 |
+
images.append(result.url)
|
| 56 |
+
return images
|
| 57 |
+
"""
|
| 58 |
+
|
| 59 |
+
theme = "Base"
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
with gr.Blocks(theme=theme) as demo:
|
| 63 |
+
gr.Markdown("""
|
| 64 |
+
# Stable Diffusion Demo
|
| 65 |
+
|
| 66 |
+
<h3></h3>
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
🚀 This space generates images by text with many settings!
|
| 70 |
+
|
| 71 |
+
⏰️ Generation on average lasts 15-25 seconds!
|
| 72 |
+
|
| 73 |
+
👥️️ This demo was created by OpenskyML and 4COM!
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
""")
|
| 78 |
+
|
| 79 |
+
gr.Image("banner.png", elem_id="banner-image", show_label=False, show_download_button=False, show_share_button=False)
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
gr.DuplicateButton(value="Duplicate space for private use")
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
with gr.Tab(label="txt2img"):
|
| 88 |
+
with gr.Row():
|
| 89 |
+
with gr.Column():
|
| 90 |
+
prompt = gr.Textbox(label="Prompt", lines=2, placeholder="beautiful cat, 8k")
|
| 91 |
+
negative = gr.Textbox(label="Negative Prompt", lines=3, value="text, blurry, fuzziness", placeholder="Add words you don't want to show up in your art...")
|
| 92 |
+
|
| 93 |
+
with gr.Row():
|
| 94 |
+
steps = gr.Slider(label="Steps", value=30, step=1, maximum=50, minimum=5, interactive=True)
|
| 95 |
+
cfg = gr.Slider(label="CFG Scale", maximum=20, minimum=1, value=7, interactive=True, info="Recommended 7 CFG Scale")
|
| 96 |
+
|
| 97 |
+
with gr.Row():
|
| 98 |
+
num = gr.Slider(label="Number of images", value=2, step=1, maximum=4, minimum=1, interactive=True)
|
| 99 |
+
seed = gr.Slider(label="Seed", value=-1, step=1, minimum=-1, maximum=4294967295, interactive=True, info="""'-1' is a random seed""")
|
| 100 |
+
|
| 101 |
+
with gr.Row():
|
| 102 |
+
model = gr.Dropdown(label="Model", choices=get_values()[0], value="v1-5-pruned-emaonly.ckpt [81761151]", interactive=True)
|
| 103 |
+
sampler = gr.Dropdown(label="Sampler", choices=get_values()[1], value="DPM++ SDE Karras", interactive=True)
|
| 104 |
+
|
| 105 |
+
with gr.Row():
|
| 106 |
+
ar = gr.Radio(label="Aspect Ratio", choices=["square", "portrait", "landscape"], value="square", interactive=True)
|
| 107 |
+
with gr.Column():
|
| 108 |
+
upscale = gr.Checkbox(label="upscale", value=True, interactive=True, info="""'True' recommended, improves image quality""")
|
| 109 |
+
|
| 110 |
+
with gr.Row():
|
| 111 |
+
run_btn = gr.Button("Generate", variant="primary")
|
| 112 |
+
with gr.Column():
|
| 113 |
+
result_image = gr.Gallery(label="Result Image(s)")
|
| 114 |
+
|
| 115 |
+
gr.Examples(
|
| 116 |
+
examples=[
|
| 117 |
+
["A high tech solarpunk utopia in the Amazon rainforest"],
|
| 118 |
+
["A pikachu fine dining with a view to the Eiffel Tower"],
|
| 119 |
+
["A mecha robot in a favela in expressionist style"],
|
| 120 |
+
["an insect robot preparing a delicious meal"],
|
| 121 |
+
["A small cabin on top of a snowy mountain in the style of Disney, artstation"]
|
| 122 |
+
],
|
| 123 |
+
|
| 124 |
+
inputs=[prompt],
|
| 125 |
+
cache_examples=False,
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
run_btn.click(
|
| 129 |
+
process_input_text2img,
|
| 130 |
+
inputs=[
|
| 131 |
+
prompt,
|
| 132 |
+
negative,
|
| 133 |
+
steps,
|
| 134 |
+
cfg,
|
| 135 |
+
num,
|
| 136 |
+
seed,
|
| 137 |
+
model,
|
| 138 |
+
sampler,
|
| 139 |
+
ar,
|
| 140 |
+
upscale
|
| 141 |
+
],
|
| 142 |
+
outputs=[result_image],
|
| 143 |
+
)
|
| 144 |
+
|
| 145 |
+
with gr.Tab(label="img2img"):
|
| 146 |
+
with gr.Row():
|
| 147 |
+
with gr.Column():
|
| 148 |
+
prompt = gr.Textbox(label="Prompt", lines=2, placeholder="beautiful cat, 8k")
|
| 149 |
+
|
| 150 |
+
with gr.Row():
|
| 151 |
+
negative = gr.Textbox(label="Negative Prompt", lines=3, placeholder="Add words you don't want to show up in your art...")
|
| 152 |
+
init_image = gr.Textbox(label="Init Image Url", lines=3, placeholder="https://cdn.openai.com/API/images/guides/image_generation_simple.webp")
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
with gr.Row():
|
| 156 |
+
steps = gr.Slider(label="Steps", value=30, step=1, maximum=50, minimum=1, interactive=True)
|
| 157 |
+
cfg = gr.Slider(label="CFG Scale", maximum=20, minimum=1, value=7, interactive=True, info="Recommended 7 CFG Scale")
|
| 158 |
+
|
| 159 |
+
with gr.Row():
|
| 160 |
+
num = gr.Slider(label="Number of images", value=2, step=1, maximum=4, minimum=1, interactive=True)
|
| 161 |
+
seed = gr.Slider(label="Seed", value=-1, step=1, minimum=-1, maximum=4294967295, interactive=True, info="""'-1' is a random seed""")
|
| 162 |
+
|
| 163 |
+
with gr.Row():
|
| 164 |
+
model = gr.Dropdown(label="Model", choices=get_values()[0], value="v1-5-pruned-emaonly.ckpt [81761151]", interactive=True)
|
| 165 |
+
sampler = gr.Dropdown(label="Sampler", choices=get_values()[1], value="DPM++ 2M Karras", interactive=True)
|
| 166 |
+
|
| 167 |
+
with gr.Row():
|
| 168 |
+
ds = gr.Slider(label="Denoising strength", maximum=0.9, minimum=0.1, value=0.5, interactive=True)
|
| 169 |
+
with gr.Column():
|
| 170 |
+
upscale = gr.Checkbox(label="upscale", value=True, interactive=True, info="""'True' recommended, improves image quality""")
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
with gr.Row():
|
| 174 |
+
run_btn = gr.Button("Generate", variant="primary")
|
| 175 |
+
with gr.Column():
|
| 176 |
+
result_image = gr.Gallery(label="Result Image(s)")
|
| 177 |
+
run_btn.click(
|
| 178 |
+
process_input_img2img,
|
| 179 |
+
inputs=[
|
| 180 |
+
init_image,
|
| 181 |
+
prompt,
|
| 182 |
+
negative,
|
| 183 |
+
steps,
|
| 184 |
+
cfg,
|
| 185 |
+
num,
|
| 186 |
+
seed,
|
| 187 |
+
model,
|
| 188 |
+
sampler,
|
| 189 |
+
ds,
|
| 190 |
+
upscale
|
| 191 |
+
],
|
| 192 |
+
outputs=[result_image],
|
| 193 |
+
)
|
| 194 |
+
|
| 195 |
+
with gr.Tab(label="Gallery"):
|
| 196 |
+
|
| 197 |
+
gr.load("nateraw/stable_diffusion_gallery", src="spaces")
|
| 198 |
+
|
| 199 |
+
with gr.Tab(label="License"):
|
| 200 |
+
|
| 201 |
+
gr.load("4com/4com-license", src="spaces")
|
| 202 |
+
|
| 203 |
+
if __name__ == "__main__":
|
| 204 |
+
demo.launch(show_api=True)
|
requirements (12).txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
requests
|
| 3 |
+
python-dotenv
|
| 4 |
+
prodiapy
|