Demo750 commited on
Commit
f0b6017
·
verified ·
1 Parent(s): 4507612

Update Webpage.py

Browse files
Files changed (1) hide show
  1. Webpage.py +12 -5
Webpage.py CHANGED
@@ -42,10 +42,17 @@ def calculate_areas(prompts, brand_num, pictorial_num, text_num):
42
  ad_size += np.abs((x1-x2)*(y1-y2))
43
  ad_image = image_entire[int(y1):int(y2), int(x1):int(x2), :]
44
  left_margin = x1; right_margin = w-x2
45
- if left_margin >= right_margin:
46
- context_image = image_entire[:, :int(x1), :]
 
 
 
 
47
  else:
48
- context_image = image_entire[:, int(x2):, :]
 
 
 
49
 
50
  whole_size = 0
51
  whole_size += w*h
@@ -113,8 +120,8 @@ demo = gr.Interface(
113
     (c) Text element(s) (skip if N.A.)
114
     (d) The advertisement.
115
  NOTE: Each ad element can have more than 1 boxes."""),
116
- gr.DownloadButton(label="Example Magazine Ad Image Download", value='Demo/Magazine_Ad_Example.jpg'),
117
- gr.DownloadButton(label="Example Web Ad Image Download", value='Demo/Web_Ad_Example.jpg'),
118
  ImagePrompter(label="Upload Entire (Ad+Context) Image, and Draw Bounding Boxes", sources=['upload'], type="pil"),
119
  gr.Number(label="Number of brand bounding boxes drawn"),
120
  gr.Number(label="Number of pictorial bounding boxes drawn"),
 
42
  ad_size += np.abs((x1-x2)*(y1-y2))
43
  ad_image = image_entire[int(y1):int(y2), int(x1):int(x2), :]
44
  left_margin = x1; right_margin = w-x2
45
+ if left_margin <=100 and right_margin <= 100:
46
+ upper_margin = y1; lower_margin = h-y2
47
+ if upper_margin >= lower_margin:
48
+ context_image = image_entire[:int(y1), :, :]
49
+ else:
50
+ context_image = image_entire[int(y2):, :, :]
51
  else:
52
+ if left_margin >= right_margin:
53
+ context_image = image_entire[:, :int(x1), :]
54
+ else:
55
+ context_image = image_entire[:, int(x2):, :]
56
 
57
  whole_size = 0
58
  whole_size += w*h
 
120
  &nbsp;&nbsp;&nbsp;(c) Text element(s) (skip if N.A.)
121
  &nbsp;&nbsp;&nbsp;(d) The advertisement.
122
  NOTE: Each ad element can have more than 1 boxes."""),
123
+ gr.DownloadButton(label="Download Example Magazine Ad Image", value='Demo/Magazine_Ad_Example.jpg'),
124
+ gr.DownloadButton(label="Download Example Web Ad Image", value='Demo/Web_Ad_Example.jpg'),
125
  ImagePrompter(label="Upload Entire (Ad+Context) Image, and Draw Bounding Boxes", sources=['upload'], type="pil"),
126
  gr.Number(label="Number of brand bounding boxes drawn"),
127
  gr.Number(label="Number of pictorial bounding boxes drawn"),