Adin019 commited on
Commit
a42c19e
·
verified ·
1 Parent(s): 482834a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -12
app.py CHANGED
@@ -2,16 +2,11 @@ import gradio as gr
2
  from diffusers import StableDiffusionImg2ImgPipeline
3
  import torch
4
  from PIL import Image
5
- import base64
6
- import io
7
-
8
- MODEL_ID = "runwayml/stable-diffusion-v1-5"
9
 
10
  pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
11
- MODEL_ID,
12
  torch_dtype=torch.float32
13
  )
14
- pipe.enable_attention_slicing()
15
 
16
  def generate(image, prompt):
17
  if image is None:
@@ -19,8 +14,8 @@ def generate(image, prompt):
19
 
20
  img = image.convert("RGB").resize((512, 512))
21
 
22
- full_prompt = f"interior design, {prompt}, photorealistic, high quality, 8k, professional photography"
23
- negative_prompt = "ugly, blurry, bad quality, distorted, deformed, low resolution"
24
 
25
  result = pipe(
26
  prompt=full_prompt,
@@ -28,7 +23,7 @@ def generate(image, prompt):
28
  image=img,
29
  strength=0.75,
30
  guidance_scale=7.5,
31
- num_inference_steps=25,
32
  ).images[0]
33
 
34
  return result
@@ -37,11 +32,10 @@ demo = gr.Interface(
37
  fn=generate,
38
  inputs=[
39
  gr.Image(type="pil", label="Leeg interieur render"),
40
- gr.Textbox(label="Stijl omschrijving", placeholder="bijv: Scandinavisch minimalistisch, warme tinten, houten vloer")
41
  ],
42
  outputs=gr.Image(type="pil", label="Resultaat"),
43
- title="Interior AI",
44
- description="Upload een leeg render en beschrijf de gewenste stijl."
45
  )
46
 
47
  if __name__ == "__main__":
 
2
  from diffusers import StableDiffusionImg2ImgPipeline
3
  import torch
4
  from PIL import Image
 
 
 
 
5
 
6
  pipe = StableDiffusionImg2ImgPipeline.from_pretrained(
7
+ "hf-internal-testing/tiny-stable-diffusion-pipe",
8
  torch_dtype=torch.float32
9
  )
 
10
 
11
  def generate(image, prompt):
12
  if image is None:
 
14
 
15
  img = image.convert("RGB").resize((512, 512))
16
 
17
+ full_prompt = f"interior design, {prompt}, photorealistic, high quality"
18
+ negative_prompt = "ugly, blurry, bad quality, distorted"
19
 
20
  result = pipe(
21
  prompt=full_prompt,
 
23
  image=img,
24
  strength=0.75,
25
  guidance_scale=7.5,
26
+ num_inference_steps=8,
27
  ).images[0]
28
 
29
  return result
 
32
  fn=generate,
33
  inputs=[
34
  gr.Image(type="pil", label="Leeg interieur render"),
35
+ gr.Textbox(label="Stijl omschrijving")
36
  ],
37
  outputs=gr.Image(type="pil", label="Resultaat"),
38
+ title="Interior AI"
 
39
  )
40
 
41
  if __name__ == "__main__":