from text2image import GenerateImage, Nodes, ComfyUIGenerateImageForm, load_workflow import random, os, gradio def generate(prompt: str): base_url = "http://172.22.0.29:8188" client_id = "test_client" image_file_name = "test.png" image_file_folder = "CodeNight/text2image/images" workflow_json = load_workflow("CodeNight/text2image/malerisch.json") nodes = Nodes( prompt=6, negative_prompt=7, width=5, height=5, seed=3, steps=3 ) payload = ComfyUIGenerateImageForm( workflow=workflow_json, nodes=nodes, # prompt="fashion photography of 23 y.o blonde woman, beautiful makeup, wearing dot dress, 35mm", # prompt="b/w fashion photography of 23 y.o black man, instgram, 35mm", # prompt="Cyberpunk android with glowing eyes, beautiful face, urban background, neon accents, high-tech, realistic style.", # prompt="Cyberpunk rooftop scene, overlooking city, neon lights, futuristic skyline, atmospheric style.", # prompt="A goat with sun glasses on a skateboard. realistic. skatepark, sunny day. 35mm", prompt=prompt, width=768, height=768, negative_prompt=" (octane render, render, drawing, anime, bad photo, bad photography:1.3), (worst quality, low quality, blurry:1.2), (bad teeth, deformed teeth, deformed lips), (bad anatomy, bad proportions:1.1), (deformed iris, deformed pupils), (deformed eyes, bad eyes), (deformed face, ugly face, bad face), (deformed hands, bad hands, fused fingers), morbid, mutilated, mutation, disfigured", seed=random.randint(0, 1125899906842624), steps=30 ) GenerateImage(payload, client_id, base_url, image_file_folder, image_file_name) return os.path.join(image_file_folder, image_file_name) with gradio.Blocks() as demo: gradio.Markdown("# Meine erste Webanwendung") with gradio.Row(equal_height=True): textbox = gradio.Textbox(lines=1, show_label=False, placeholder="Gib hier deinen Prompt ein") button = gradio.Button("Generate", variant="primary") image = gradio.Image(height=768) button.click( generate, inputs=textbox, outputs=image ) if __name__ == "__main__": demo.launch(share=True)