Spaces:
Runtime error
Runtime error
import gradio as gr | |
import os | |
from huggingface_hub import InferenceClient | |
import io | |
from PIL import Image | |
clientA = InferenceClient(model="xiaolxl/GuoFeng3") | |
clientB = InferenceClient(model="stabilityai/stable-diffusion-2-1") | |
def getImageA(inputs, nprompt): return getImage(inputs, nprompt, clientA) | |
def getImageB(inputs, nprompt): return getImage(inputs, nprompt, clientB) | |
def getImage(inputs, nprompt, client): | |
parameters = { | |
"negative_prompt": nprompt | |
} | |
response = client.post(json={ | |
"options": { "use_cache": False }, | |
"inputs": inputs, | |
"parameters": parameters}) | |
image =Image.open(io.BytesIO(response.content)) | |
return image | |
with gr.Blocks() as demo: | |
with gr.Row(): | |
with gr.Column(): | |
image=gr.Image(shape=(512,512)) | |
with gr.Column(): | |
txt_1 = gr.Textbox(label="prompt", lines=2, value="masterpiece, best quality, high quality,extremely detailed CG unity 8k , ((lotus in the lake)) , An enchanting and dreamy scene of a fantasy forest, with towering trees, creating a sense of mystique and enchantment, artstation, digital illustration, intricate, trending, pastel colors, oil paiting, award winning photography, Bokeh, Depth of Field, HDR, bloom, Chromatic Aberration ,Photorealistic,extremely detailed, trending on artstation, trending on CGsociety, Intricate, High Detail, dramatic, art by midjourney ") | |
txt_2 = gr.Textbox(label="negative", lines=2, value="windows, canvas frame, cartoon, 3d, ((disfigured)), ((bad art)), ((deformed)),((extra limbs)),((close up)),((b&w)), wierd colors, blurry, (((duplicate))), ((morbid)), ((mutilated)), [out of frame], extra fingers, mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), blurry, ((bad anatomy)), (((bad proportions))), ((extra limbs)), cloned face, (((disfigured))), out of frame, extra limbs, (bad anatomy), gross proportions, (malformed limbs), ((missing arms)), ((missing legs)), (((extra arms))), (((extra legs))), mutated hands, (fused fingers), (too many fingers), (((long neck))), Photoshop, video game, tiling, poorly drawn hands, poorly drawn feet, poorly drawn face, out of frame, mutation, mutated, extra limbs, extra legs, extra arms, disfigured, deformed, cross-eye, body out of frame, blurry, bad art, bad anatomy, 3d render, ((naked)), ((nude)), ((NSFW)), (((claws)))") | |
gr.Button(value="SubmitA").click(getImageA, inputs=[txt_1, txt_2], outputs=[image]) | |
gr.Button(value="SubmitB").click(getImageB, inputs=[txt_1, txt_2], outputs=[image]) | |
if __name__ == "__main__": | |
demo.launch() |