Update app.py
Browse files
app.py
CHANGED
@@ -10,10 +10,15 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
10 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
|
11 |
pipe = pipe.to(device)
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
def infer(source_img, prompt, negative_prompt, guide, steps, seed, Strength):
|
14 |
generator = torch.Generator(device).manual_seed(seed)
|
15 |
-
|
16 |
-
image = pipe(prompt, negative_prompt=negative_prompt, image=
|
17 |
return image
|
18 |
|
19 |
gr.Interface(fn=infer, inputs=[gr.Image(source='canvas'), gr.Textbox(label = 'Prompt Input Text. 77 Token (Keyword or Symbol) Maximum'), gr.Textbox(label='What you Do Not want the AI to generate.'),
|
|
|
10 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16) if torch.cuda.is_available() else DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0")
|
11 |
pipe = pipe.to(device)
|
12 |
|
13 |
+
def resize(value,img):
|
14 |
+
img = Image.open(img)
|
15 |
+
img = img.resize((value,value))
|
16 |
+
return img
|
17 |
+
|
18 |
def infer(source_img, prompt, negative_prompt, guide, steps, seed, Strength):
|
19 |
generator = torch.Generator(device).manual_seed(seed)
|
20 |
+
src = resize(768, source_img)
|
21 |
+
image = pipe(prompt, negative_prompt=negative_prompt, image=src, strength=Strength, guidance_scale=guide, num_inference_steps=steps).images[0]
|
22 |
return image
|
23 |
|
24 |
gr.Interface(fn=infer, inputs=[gr.Image(source='canvas'), gr.Textbox(label = 'Prompt Input Text. 77 Token (Keyword or Symbol) Maximum'), gr.Textbox(label='What you Do Not want the AI to generate.'),
|