beva commited on
Commit
bd1777e
·
verified ·
1 Parent(s): afaede9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from torch import autocast
4
+ from diffusers import StableDiffusionXLPipeline, EulerAncestralDiscreteScheduler
5
+
6
+ model = "linaqruf/animagine-xl"
7
+
8
+ pipe = StableDiffusionXLPipeline.from_pretrained(
9
+ model,
10
+ torch_dtype=torch.float16,
11
+ use_safetensors=True,
12
+ variant="fp16",
13
+ )
14
+ pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
15
+ pipe.to('cuda')
16
+
17
+ def launch(prompt, negative_prompt):
18
+ prompt += " ,awesome, pixel art"
19
+ negative_prompt += ", lowres, bad anatomy, bad hands, text, error, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality, normal quality, jpeg artifacts, signature, watermark, username, blurry"
20
+ image = pipe(prompt,
21
+ negative_prompt=negative_prompt,
22
+ width=1024,
23
+ height=1024,
24
+ guidance_scale=12,
25
+ target_size=(1024, 1024),
26
+ original_size=(4096, 4096),
27
+ num_inference_steps=50)
28
+ return image.images[0] # Assuming this is how you get the resulting image
29
+
30
+ iface = gr.Interface(fn=launch,
31
+ inputs=[gr.Textbox(label="Prompt"), gr.Textbox(label="Negative Prompt")],
32
+ outputs=gr.Image(type='pil'),
33
+ title="Generate Images",
34
+ description="Enter a prompt and a negative prompt to generate an image.")
35
+ iface.launch()