ahmadarrabi commited on
Commit
caadc58
·
verified ·
1 Parent(s): dd071f7
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -11,12 +11,11 @@ def sketch_transform(size):
11
 
12
  def generate_image(image):
13
  if image is not None:
14
- sketch = image #['layers'][0]
15
  sketch = transforms.ToTensor()(sketch).unsqueeze(0)
16
  sketch = sketch_transform(size=(256,256))(sketch)
17
  sketch = sketch/255.
18
- print(sketch.shape)
19
- print(type(sketch))
20
  with torch.no_grad(): # Disable gradient calculation for inference
21
  prompt='Realistic Seattle aerial satellite top view image with high quality details with buildings and roads in Seattle that probably has the following objects and characteristics: houses neighborhood city urban modern'
22
  model_output = pipe(prompt, num_inference_steps=20, generator=torch.manual_seed(0), image=sketch)
@@ -41,19 +40,22 @@ pipe.enable_model_cpu_offload(device=device)
41
  iface = gr.Interface(
42
  fn=generate_image,
43
  inputs=[
44
- gr.ImageEditor(sources=(), brush=gr.Brush(colors=["#ffb266", #building
45
- "#4059ff", #parking
46
- "#66ff66", #grass
47
- #"#009900", #forest
48
- "#cce5ff", #water
49
- #"#c0c0c0", #path
50
- "#606060" #road
51
- ], color_mode="fixed"))
 
 
 
52
  #gr.Sketchpad()
53
  #gr.Image(shape=(512, 512), source="canvas", tool="sketch", image_mode="RGB", invert_colors=False, brush_color="black"),
54
  #gr.Dropdown(choices=allowed_colors, label="Brush Color")
55
  ],
56
- outputs=gr.Image()
57
  )
58
 
59
  iface.launch()
 
11
 
12
  def generate_image(image):
13
  if image is not None:
14
+ sketch = image['layers'][0]
15
  sketch = transforms.ToTensor()(sketch).unsqueeze(0)
16
  sketch = sketch_transform(size=(256,256))(sketch)
17
  sketch = sketch/255.
18
+
 
19
  with torch.no_grad(): # Disable gradient calculation for inference
20
  prompt='Realistic Seattle aerial satellite top view image with high quality details with buildings and roads in Seattle that probably has the following objects and characteristics: houses neighborhood city urban modern'
21
  model_output = pipe(prompt, num_inference_steps=20, generator=torch.manual_seed(0), image=sketch)
 
40
  iface = gr.Interface(
41
  fn=generate_image,
42
  inputs=[
43
+ gr.ImageEditor(sources=(),
44
+ image_mode='RGB',
45
+ brush=gr.Brush(colors=["#ffb266", #building
46
+ "#4059ff", #parking
47
+ "#66ff66", #grass
48
+ #"#009900", #forest
49
+ "#cce5ff", #water
50
+ #"#c0c0c0", #path
51
+ "#606060" #road
52
+ ], color_mode="fixed")
53
+ )
54
  #gr.Sketchpad()
55
  #gr.Image(shape=(512, 512), source="canvas", tool="sketch", image_mode="RGB", invert_colors=False, brush_color="black"),
56
  #gr.Dropdown(choices=allowed_colors, label="Brush Color")
57
  ],
58
+ outputs="image"
59
  )
60
 
61
  iface.launch()