T.Masuda commited on
Commit
cdedf96
·
1 Parent(s): 436d7af

update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -17
app.py CHANGED
@@ -7,7 +7,7 @@ def check_location(image, enable1, left1, top1, enable2, left2, top2, enable3, l
7
  if image is None:
8
  yield None
9
  return
10
- if not enable1 and not enable2 and not enable3:
11
  yield None
12
  return
13
 
@@ -32,7 +32,7 @@ def process_image(image, enable1, left1, top1, enable2, left2, top2, enable3, le
32
  if image is None:
33
  yield None
34
  return
35
- if not enable1 and not enable2 and not enable3:
36
  yield None
37
  return
38
 
@@ -65,16 +65,7 @@ def process_image(image, enable1, left1, top1, enable2, left2, top2, enable3, le
65
  yield newImage
66
 
67
  def tab_select(evt: gr.SelectData, state):
68
- if evt.target.label == 'point2':
69
- state['active'] = 1
70
- elif evt.target.label == 'point3':
71
- state['active'] = 2
72
- elif evt.target.label == 'point4':
73
- state['active'] = 3
74
- elif evt.target.label == 'point5':
75
- state['active'] = 4
76
- else:
77
- state['active'] = 0
78
  return state
79
 
80
  def image_select(evt: gr.SelectData, state, enable1, left1, top1, enable2, left2, top2, enable3, left3, top3, enable4, left4, top4, enable5, left5, top5):
@@ -99,23 +90,23 @@ with gr.Blocks(title='clip-image') as app:
99
  with gr.Column():
100
  image = gr.Image(type='pil')
101
  gr.Markdown('click on the image to position')
102
- with gr.Tab("point1") as tab1:
103
  enable1 = gr.Checkbox(label='enable', value=True)
104
  left1 = gr.Slider(maximum=4000, step=1, label='left')
105
  top1 = gr.Slider(maximum=4000, step=1, label='top')
106
- with gr.Tab("point2") as tab2:
107
  enable2 = gr.Checkbox(label='enable')
108
  left2 = gr.Slider(maximum=4000, step=1, label='left')
109
  top2 = gr.Slider(maximum=4000, step=1, label='top')
110
- with gr.Tab("point3") as tab3:
111
  enable3 = gr.Checkbox(label='enable')
112
  left3 = gr.Slider(maximum=4000, step=1, label='left')
113
  top3 = gr.Slider(maximum=4000, step=1, label='top')
114
- with gr.Tab("point4") as tab4:
115
  enable4 = gr.Checkbox(label='enable')
116
  left4 = gr.Slider(maximum=4000, step=1, label='left')
117
  top4 = gr.Slider(maximum=4000, step=1, label='top')
118
- with gr.Tab("point5") as tab5:
119
  enable5 = gr.Checkbox(label='enable')
120
  left5 = gr.Slider(maximum=4000, step=1, label='left')
121
  top5 = gr.Slider(maximum=4000, step=1, label='top')
 
7
  if image is None:
8
  yield None
9
  return
10
+ if not enable1 and not enable2 and not enable3 and not enable4 and not enable5:
11
  yield None
12
  return
13
 
 
32
  if image is None:
33
  yield None
34
  return
35
+ if not enable1 and not enable2 and not enable3 and not enable4 and not enable5:
36
  yield None
37
  return
38
 
 
65
  yield newImage
66
 
67
  def tab_select(evt: gr.SelectData, state):
68
+ state['active'] = evt.target.id
 
 
 
 
 
 
 
 
 
69
  return state
70
 
71
  def image_select(evt: gr.SelectData, state, enable1, left1, top1, enable2, left2, top2, enable3, left3, top3, enable4, left4, top4, enable5, left5, top5):
 
90
  with gr.Column():
91
  image = gr.Image(type='pil')
92
  gr.Markdown('click on the image to position')
93
+ with gr.Tab('point1', id=0) as tab1:
94
  enable1 = gr.Checkbox(label='enable', value=True)
95
  left1 = gr.Slider(maximum=4000, step=1, label='left')
96
  top1 = gr.Slider(maximum=4000, step=1, label='top')
97
+ with gr.Tab('point2', id=1) as tab2:
98
  enable2 = gr.Checkbox(label='enable')
99
  left2 = gr.Slider(maximum=4000, step=1, label='left')
100
  top2 = gr.Slider(maximum=4000, step=1, label='top')
101
+ with gr.Tab('point3', id=2) as tab3:
102
  enable3 = gr.Checkbox(label='enable')
103
  left3 = gr.Slider(maximum=4000, step=1, label='left')
104
  top3 = gr.Slider(maximum=4000, step=1, label='top')
105
+ with gr.Tab('point4', id=3) as tab4:
106
  enable4 = gr.Checkbox(label='enable')
107
  left4 = gr.Slider(maximum=4000, step=1, label='left')
108
  top4 = gr.Slider(maximum=4000, step=1, label='top')
109
+ with gr.Tab('point5', id=4) as tab5:
110
  enable5 = gr.Checkbox(label='enable')
111
  left5 = gr.Slider(maximum=4000, step=1, label='left')
112
  top5 = gr.Slider(maximum=4000, step=1, label='top')