Spaces:
Runtime error
Runtime error
Commit
·
a3b506f
1
Parent(s):
cbc1dd0
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
-
import os
|
| 4 |
-
import base64
|
| 5 |
-
from PIL import Image
|
| 6 |
-
import io
|
| 7 |
|
| 8 |
-
|
| 9 |
-
api_url = "https://codinglehrer.pythonanywhere.com/generate_image"
|
| 10 |
|
| 11 |
def generate_image(prompt, seed=0, negative_prompt="", model="Deliberate", sampler="k_dpmpp_2s_a", steps=50):
|
| 12 |
data = {
|
|
@@ -17,70 +12,17 @@ def generate_image(prompt, seed=0, negative_prompt="", model="Deliberate", sampl
|
|
| 17 |
"sampler": sampler,
|
| 18 |
"steps": steps
|
| 19 |
}
|
| 20 |
-
response = requests.post(api_url, data=data
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
img = Image.open(io.BytesIO(img_bytes))
|
| 26 |
-
|
| 27 |
-
# Return the image object
|
| 28 |
-
return img
|
| 29 |
|
| 30 |
inputs = [
|
| 31 |
gr.inputs.Textbox(label="Prompt"),
|
| 32 |
gr.inputs.Number(label="Seed", default=0),
|
| 33 |
gr.inputs.Textbox(label="Negative Prompt", default=""),
|
| 34 |
-
gr.inputs.Dropdown([
|
| 35 |
-
'AIO Pixel Art', 'Analog Diffusion', 'Anime Pencil Diffusion', 'Anygen',
|
| 36 |
-
'Anything Diffusion', 'Anything v3', 'anything_v4_inpainting',
|
| 37 |
-
'App Icon Diffusion', 'Arcane Diffusion', 'Archer Diffusion',
|
| 38 |
-
'Asim Simpsons', 'A to Zovya RPG', 'Balloon Art', 'Borderlands', 'BPModel',
|
| 39 |
-
'BubblyDubbly', 'Char', 'CharHelper', 'Cheese Daddys Landscape Mix',
|
| 40 |
-
'ChilloutMix', 'ChromaV5', 'Classic Animation Diffusion', 'Clazy',
|
| 41 |
-
'Colorful', 'Coloring Book', 'Comic-Diffusion', 'Concept Sheet',
|
| 42 |
-
'Counterfeit', 'Cyberpunk Anime Diffusion', 'CyriousMix',
|
| 43 |
-
'Dan Mumford Style', 'Darkest Diffusion', 'Dark Victorian Diffusion',
|
| 44 |
-
'Deliberate', 'DGSpitzer Art Diffusion', 'Disco Elysium', 'DnD Item',
|
| 45 |
-
'Double Exposure Diffusion', 'Dreamlike Diffusion',
|
| 46 |
-
'dreamlike_diffusion_inpainting', 'Dreamlike Photoreal',
|
| 47 |
-
'DreamLikeSamKuvshinov', 'Dreamshaper', 'DucHaiten',
|
| 48 |
-
'DucHaiten Classic Anime', 'Dungeons and Diffusion', 'Dungeons n Waifus',
|
| 49 |
-
'Eimis Anime Diffusion', 'Elden Ring Diffusion', "Elldreth's Lucid Mix",
|
| 50 |
-
'Elldreths Retro Mix', 'Epic Diffusion', 'Eternos', 'Experience',
|
| 51 |
-
'ExpMix Line', 'FaeTastic', 'Fantasy Card Diffusion', 'FKing SciFi',
|
| 52 |
-
'Funko Diffusion', 'Furry Epoch', 'Future Diffusion', 'Ghibli Diffusion',
|
| 53 |
-
'GorynichMix', 'Grapefruit Hentai', 'Graphic-Art',
|
| 54 |
-
'GTA5 Artwork Diffusion', 'GuoFeng', 'Guohua Diffusion', 'HASDX',
|
| 55 |
-
'Hassanblend', "Healy's Anime Blend", 'Hentai Diffusion', 'HRL', 'iCoMix',
|
| 56 |
-
'Illuminati Diffusion', 'Inkpunk Diffusion', 'Jim Eidomode',
|
| 57 |
-
'JWST Deep Space Diffusion', 'Kenshi', 'Knollingcase', 'Korestyle',
|
| 58 |
-
'kurzgesagt', 'Laolei New Berry Protogen Mix', "Lawlas's yiff mix",
|
| 59 |
-
'Liberty', 'Marvel Diffusion', 'Mega Merge Diffusion', 'Microcasing',
|
| 60 |
-
'Microchars', 'Microcritters', 'Microscopic', 'Microworlds',
|
| 61 |
-
'Midjourney Diffusion', 'Midjourney PaintArt', 'Min Illust Background',
|
| 62 |
-
'ModernArt Diffusion', 'mo-di-diffusion', 'Moedel', 'MoistMix',
|
| 63 |
-
'Movie Diffusion', 'NeverEnding Dream', 'Nitro Diffusion', 'Openniji',
|
| 64 |
-
'OrbAI', 'Papercutcraft', 'Papercut Diffusion', 'Pastel Mix',
|
| 65 |
-
'Perfect World', 'PFG', 'PIXHELL', 'Poison', 'Pokemon3D', 'PortraitPlus',
|
| 66 |
-
'PPP', 'Pretty 2.5D', 'PRMJ', 'Project Unreal Engine 5', 'ProtoGen',
|
| 67 |
-
'Protogen Anime', 'Protogen Infinity', 'Pulp Vector Art', 'PVC',
|
| 68 |
-
'Rachel Walker Watercolors', 'Rainbowpatch', 'Ranma Diffusion',
|
| 69 |
-
'RCNZ Dumb Monkey', 'RCNZ Gorilla With A Brick', 'RealBiter',
|
| 70 |
-
'Realism Engine', 'Realistic Vision', 'Redshift Diffusion', 'Rev Animated',
|
| 71 |
-
'Robo-Diffusion', 'Rodent Diffusion', 'RPG', 'Samdoesarts Ultmerge',
|
| 72 |
-
'Sci-Fi Diffusion', 'SD-Silicon', 'Seek.art MEGA', 'Smoke Diffusion',
|
| 73 |
-
'Something', 'Sonic Diffusion', 'Spider-Verse Diffusion',
|
| 74 |
-
'Squishmallow Diffusion', 'stable_diffusion', 'stable_diffusion_2.1',
|
| 75 |
-
'stable_diffusion_2_inpainting', 'Supermarionation', 'Sygil-Dev Diffusion',
|
| 76 |
-
'Synthwave', 'SynthwavePunk', 'TrexMix', 'trinart', 'Trinart Characters',
|
| 77 |
-
'Tron Legacy Diffusion', 'T-Shirt Diffusion', 'T-Shirt Print Designs',
|
| 78 |
-
'Uhmami', 'Ultraskin', 'UMI Olympus', 'Unstable Ink Dream', 'URPM',
|
| 79 |
-
'Valorant Diffusion', 'Van Gogh Diffusion', 'Vector Art', 'vectorartz',
|
| 80 |
-
'Vintedois Diffusion', 'VinteProtogenMix', 'Vivid Watercolors',
|
| 81 |
-
'Voxel Art Diffusion', 'waifu_diffusion', 'Wavyfusion', 'Woop-Woop Photo',
|
| 82 |
-
'Xynthii-Diffusion', 'Yiffy', 'Zack3D', 'Zeipher Female Model',
|
| 83 |
-
'Zelda BOTW'], label="Model", default="Deliberate"),
|
| 84 |
gr.inputs.Dropdown(["k_lms", "k_heun", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "DDIM", "k_dpm_fast", "k_dpm_adaptive", "k_dpmpp_2m", "k_dpmpp_2s_a", "k_dpmpp_sde"], label="Sampler", default="k_dpmpp_2s_a"),
|
| 85 |
gr.inputs.Number(label="Steps", default=50)
|
| 86 |
]
|
|
@@ -88,6 +30,9 @@ inputs = [
|
|
| 88 |
outputs = gr.outputs.Image(label="Generated Image", type="pil")
|
| 89 |
|
| 90 |
interface = gr.Interface(generate_image, inputs, outputs, title="<a href='https://huggingface.co/spaces/ImagineAI-Real/ImagineAI-Image-Generator'>ImagineAI-Real/ImagineAI Image Generator</a>",
|
| 91 |
-
description="Enter a prompt, click Submit and wait a bit for your image.<br/>If taking too long, duplicate the space
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
api_url = "https://5cb20b40-572c-426f-9466-995256f9b6eb.id.repl.co/generate_image"
|
|
|
|
| 5 |
|
| 6 |
def generate_image(prompt, seed=0, negative_prompt="", model="Deliberate", sampler="k_dpmpp_2s_a", steps=50):
|
| 7 |
data = {
|
|
|
|
| 12 |
"sampler": sampler,
|
| 13 |
"steps": steps
|
| 14 |
}
|
| 15 |
+
response = requests.post(api_url, data=data)
|
| 16 |
+
if response.status_code == 200:
|
| 17 |
+
return response.json()["url"]
|
| 18 |
+
else:
|
| 19 |
+
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
inputs = [
|
| 22 |
gr.inputs.Textbox(label="Prompt"),
|
| 23 |
gr.inputs.Number(label="Seed", default=0),
|
| 24 |
gr.inputs.Textbox(label="Negative Prompt", default=""),
|
| 25 |
+
gr.inputs.Dropdown([], label="Model", default="Deliberate"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
gr.inputs.Dropdown(["k_lms", "k_heun", "k_euler", "k_euler_a", "k_dpm_2", "k_dpm_2_a", "DDIM", "k_dpm_fast", "k_dpm_adaptive", "k_dpmpp_2m", "k_dpmpp_2s_a", "k_dpmpp_sde"], label="Sampler", default="k_dpmpp_2s_a"),
|
| 27 |
gr.inputs.Number(label="Steps", default=50)
|
| 28 |
]
|
|
|
|
| 30 |
outputs = gr.outputs.Image(label="Generated Image", type="pil")
|
| 31 |
|
| 32 |
interface = gr.Interface(generate_image, inputs, outputs, title="<a href='https://huggingface.co/spaces/ImagineAI-Real/ImagineAI-Image-Generator'>ImagineAI-Real/ImagineAI Image Generator</a>",
|
| 33 |
+
description="Enter a prompt, click Submit and wait a bit for your image.<br/>If taking too long, duplicate the space.",
|
| 34 |
+
examples=[["A cat sitting on a chair"],
|
| 35 |
+
["A landscape with mountains and a lake"],
|
| 36 |
+
["A portrait of a woman with red hair"]])
|
| 37 |
|
| 38 |
+
interface.launch()
|