HaochenGong commited on
Commit
3c01c57
·
1 Parent(s): 30db3b4
Files changed (4) hide show
  1. .idea/workspace.xml +83 -16
  2. app.py +108 -6
  3. web_page.css +49 -34
  4. web_page.html +47 -293
.idea/workspace.xml CHANGED
@@ -4,8 +4,10 @@
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
- <list default="true" id="5e4481c0-7ba2-42e4-bbe6-4c36a0d36baa" name="Changes" comment="adjust style">
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
 
 
9
  <change beforePath="$PROJECT_DIR$/web_page.html" beforeDir="false" afterPath="$PROJECT_DIR$/web_page.html" afterDir="false" />
10
  </list>
11
  <option name="SHOW_DIALOG" value="false" />
@@ -32,19 +34,20 @@
32
  <option name="hideEmptyMiddlePackages" value="true" />
33
  <option name="showLibraryContents" value="true" />
34
  </component>
35
- <component name="PropertiesComponent">{
36
- &quot;keyToString&quot;: {
37
- &quot;DefaultHtmlFileTemplate&quot;: &quot;HTML File&quot;,
38
- &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
39
- &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
40
- &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
41
- &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
42
- &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
43
- &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
44
- &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
45
- &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
 
46
  }
47
- }</component>
48
  <component name="RecentsManager">
49
  <key name="MoveFile.RECENT_KEYS">
50
  <recent name="$PROJECT_DIR$" />
@@ -63,7 +66,7 @@
63
  <workItem from="1723386893769" duration="12000" />
64
  <workItem from="1723386970626" duration="451000" />
65
  <workItem from="1723387453009" duration="27328000" />
66
- <workItem from="1723978405562" duration="2241000" />
67
  </task>
68
  <task id="LOCAL-00001" summary="create">
69
  <created>1723387548126</created>
@@ -303,7 +306,70 @@
303
  <option name="project" value="LOCAL" />
304
  <updated>1723980132468</updated>
305
  </task>
306
- <option name="localTasksCounter" value="35" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  <servers />
308
  </component>
309
  <component name="TypeScriptGeneratedFilesManager">
@@ -323,6 +389,7 @@
323
  <MESSAGE value="debug" />
324
  <MESSAGE value="change the restart time to 1 day" />
325
  <MESSAGE value="adjust style" />
326
- <option name="LAST_COMMIT_MESSAGE" value="adjust style" />
 
327
  </component>
328
  </project>
 
4
  <option name="autoReloadType" value="SELECTIVE" />
5
  </component>
6
  <component name="ChangeListManager">
7
+ <list default="true" id="5e4481c0-7ba2-42e4-bbe6-4c36a0d36baa" name="Changes" comment="js">
8
  <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
9
+ <change beforePath="$PROJECT_DIR$/app.py" beforeDir="false" afterPath="$PROJECT_DIR$/app.py" afterDir="false" />
10
+ <change beforePath="$PROJECT_DIR$/web_page.css" beforeDir="false" afterPath="$PROJECT_DIR$/web_page.css" afterDir="false" />
11
  <change beforePath="$PROJECT_DIR$/web_page.html" beforeDir="false" afterPath="$PROJECT_DIR$/web_page.html" afterDir="false" />
12
  </list>
13
  <option name="SHOW_DIALOG" value="false" />
 
34
  <option name="hideEmptyMiddlePackages" value="true" />
35
  <option name="showLibraryContents" value="true" />
36
  </component>
37
+ <component name="PropertiesComponent"><![CDATA[{
38
+ "keyToString": {
39
+ "DefaultHtmlFileTemplate": "HTML File",
40
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
41
+ "RunOnceActivity.ShowReadmeOnStart": "true",
42
+ "WebServerToolWindowFactoryState": "false",
43
+ "node.js.detected.package.eslint": "true",
44
+ "node.js.detected.package.tslint": "true",
45
+ "node.js.selected.package.eslint": "(autodetect)",
46
+ "node.js.selected.package.tslint": "(autodetect)",
47
+ "nodejs_package_manager_path": "npm",
48
+ "vue.rearranger.settings.migration": "true"
49
  }
50
+ }]]></component>
51
  <component name="RecentsManager">
52
  <key name="MoveFile.RECENT_KEYS">
53
  <recent name="$PROJECT_DIR$" />
 
66
  <workItem from="1723386893769" duration="12000" />
67
  <workItem from="1723386970626" duration="451000" />
68
  <workItem from="1723387453009" duration="27328000" />
69
+ <workItem from="1723978405562" duration="17227000" />
70
  </task>
71
  <task id="LOCAL-00001" summary="create">
72
  <created>1723387548126</created>
 
306
  <option name="project" value="LOCAL" />
307
  <updated>1723980132468</updated>
308
  </task>
309
+ <task id="LOCAL-00035" summary="adjust style">
310
+ <created>1723980657743</created>
311
+ <option name="number" value="00035" />
312
+ <option name="presentableId" value="LOCAL-00035" />
313
+ <option name="project" value="LOCAL" />
314
+ <updated>1723980657743</updated>
315
+ </task>
316
+ <task id="LOCAL-00036" summary="adjust style">
317
+ <created>1723981735701</created>
318
+ <option name="number" value="00036" />
319
+ <option name="presentableId" value="LOCAL-00036" />
320
+ <option name="project" value="LOCAL" />
321
+ <updated>1723981735701</updated>
322
+ </task>
323
+ <task id="LOCAL-00037" summary="adjust style">
324
+ <created>1723981892558</created>
325
+ <option name="number" value="00037" />
326
+ <option name="presentableId" value="LOCAL-00037" />
327
+ <option name="project" value="LOCAL" />
328
+ <updated>1723981892558</updated>
329
+ </task>
330
+ <task id="LOCAL-00038" summary="adjust style">
331
+ <created>1723982234515</created>
332
+ <option name="number" value="00038" />
333
+ <option name="presentableId" value="LOCAL-00038" />
334
+ <option name="project" value="LOCAL" />
335
+ <updated>1723982234515</updated>
336
+ </task>
337
+ <task id="LOCAL-00039" summary="adjust style">
338
+ <created>1723982610151</created>
339
+ <option name="number" value="00039" />
340
+ <option name="presentableId" value="LOCAL-00039" />
341
+ <option name="project" value="LOCAL" />
342
+ <updated>1723982610151</updated>
343
+ </task>
344
+ <task id="LOCAL-00040" summary="adjust style">
345
+ <created>1723982945627</created>
346
+ <option name="number" value="00040" />
347
+ <option name="presentableId" value="LOCAL-00040" />
348
+ <option name="project" value="LOCAL" />
349
+ <updated>1723982945627</updated>
350
+ </task>
351
+ <task id="LOCAL-00041" summary="adjust style">
352
+ <created>1723983156852</created>
353
+ <option name="number" value="00041" />
354
+ <option name="presentableId" value="LOCAL-00041" />
355
+ <option name="project" value="LOCAL" />
356
+ <updated>1723983156852</updated>
357
+ </task>
358
+ <task id="LOCAL-00042" summary="adjust style">
359
+ <created>1723983607190</created>
360
+ <option name="number" value="00042" />
361
+ <option name="presentableId" value="LOCAL-00042" />
362
+ <option name="project" value="LOCAL" />
363
+ <updated>1723983607190</updated>
364
+ </task>
365
+ <task id="LOCAL-00043" summary="js">
366
+ <created>1724027789846</created>
367
+ <option name="number" value="00043" />
368
+ <option name="presentableId" value="LOCAL-00043" />
369
+ <option name="project" value="LOCAL" />
370
+ <updated>1724027789846</updated>
371
+ </task>
372
+ <option name="localTasksCounter" value="44" />
373
  <servers />
374
  </component>
375
  <component name="TypeScriptGeneratedFilesManager">
 
389
  <MESSAGE value="debug" />
390
  <MESSAGE value="change the restart time to 1 day" />
391
  <MESSAGE value="adjust style" />
392
+ <MESSAGE value="js" />
393
+ <option name="LAST_COMMIT_MESSAGE" value="js" />
394
  </component>
395
  </project>
app.py CHANGED
@@ -1,7 +1,12 @@
 
 
 
1
  import gradio as gr
2
  import cv2
3
  import numpy as np
4
  import shutil
 
 
5
  from bs4 import BeautifulSoup
6
  import requests
7
  import pandas as pd
@@ -269,6 +274,7 @@ def example_inference_3():
269
  def new_example_inference_1():
270
  image_input_bgr = cv2.imread("examples/6-8.jpg")
271
  image_input = cv2.cvtColor(image_input_bgr, cv2.COLOR_BGR2RGB)
 
272
  text_input = 'https://www.whatsapp.com/legal/privacy-policy'
273
 
274
  out_result_bgr = cv2.imread("results/result_1.png")
@@ -277,7 +283,9 @@ def new_example_inference_1():
277
  out_segment = pd.read_excel("results/result_1_S.xlsx")
278
  complete_result = pd.read_excel("results/result_1_C.xlsx")
279
 
280
- return image_input, text_input, out_result, out_segment, complete_result
 
 
281
 
282
  def new_example_inference_2():
283
  image_input_bgr = cv2.imread("examples/11-9.jpg")
@@ -305,16 +313,110 @@ def new_example_inference_3():
305
 
306
  return image_input, text_input, out_result, out_segment, complete_result
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  # def toggle_dataframe_callback():
309
  # complete_result_dataframe.visible = not complete_result_dataframe.visible
310
 
311
 
312
- with open('web_page.html', 'r', encoding='utf-8') as file:
313
- html_content = file.read()
314
 
315
  with gr.Blocks() as demo:
316
- gr.HTML(html_content)
317
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  eg_btn1 = gr.Button("Example 1", elem_id="example1", visible=False)
319
  eg_btn2 = gr.Button("Example 2", elem_id="example2", visible=False)
320
  eg_btn3 = gr.Button("Example 3", elem_id="example3", visible=False)
@@ -419,7 +521,7 @@ threading.Thread(target=schedule_restarts, args=(24,)).start() # restart per 24
419
  threading.Thread(target=schedule_monitoring, args=(12,)).start() # monitor resources using per 12 hours
420
 
421
  try:
422
- demo.launch()
423
  logger.info('Gradio app launched successfully')
424
  except Exception as e:
425
  logger.error('Error occurred while launching Gradio app', exc_info=True)
 
1
+ import base64
2
+ from io import BytesIO
3
+
4
  import gradio as gr
5
  import cv2
6
  import numpy as np
7
  import shutil
8
+
9
+ from PIL.Image import Image
10
  from bs4 import BeautifulSoup
11
  import requests
12
  import pandas as pd
 
274
  def new_example_inference_1():
275
  image_input_bgr = cv2.imread("examples/6-8.jpg")
276
  image_input = cv2.cvtColor(image_input_bgr, cv2.COLOR_BGR2RGB)
277
+
278
  text_input = 'https://www.whatsapp.com/legal/privacy-policy'
279
 
280
  out_result_bgr = cv2.imread("results/result_1.png")
 
283
  out_segment = pd.read_excel("results/result_1_S.xlsx")
284
  complete_result = pd.read_excel("results/result_1_C.xlsx")
285
 
286
+ return generate_html_with_image_and_text()
287
+
288
+ # return image_input, text_input, out_result, out_segment, complete_result
289
 
290
  def new_example_inference_2():
291
  image_input_bgr = cv2.imread("examples/11-9.jpg")
 
313
 
314
  return image_input, text_input, out_result, out_segment, complete_result
315
 
316
+
317
+ # 将图像转换为 Base64 并生成 HTML 代码
318
+ def generate_html_with_image_and_text(img_output, img_input_id, text):
319
+ # 将 NumPy 图像数组转换为 PIL 图像
320
+ out_image = Image.fromarray(img_output)
321
+
322
+ # 将图像转换为 Base64
323
+ buffered = BytesIO()
324
+ out_image.save(buffered, format="PNG")
325
+ img_base64 = base64.b64encode(buffered.getvalue()).decode("utf-8")
326
+
327
+ # 生成包含图像和文本的 HTML 代码
328
+ html_code = f"""
329
+ <div>
330
+ <img id="{img_input_id}" src="data:image/png;base64,{img_base64}" style="max-width: 100%;">
331
+ <input class="url" type="text" id="inputBox" name="inputBox" placeholder="Privacy Policy URL Link" value="{text}" />
332
+ </div>
333
+ """
334
+ return html_code
335
+
336
+
337
  # def toggle_dataframe_callback():
338
  # complete_result_dataframe.visible = not complete_result_dataframe.visible
339
 
340
 
341
+ with open('web_page.css', 'r') as css_file:
342
+ css = css_file.read()
343
 
344
  with gr.Blocks() as demo:
345
+ gr.HTML("""
346
+ <div class="title">
347
+ <div class="title_half title_content">
348
+ <h1>Cpp4App</h1>
349
+ <p>Automated Contextual Privacy Policies Generation for Mobile Apps.</p>
350
+ <div class="choice">
351
+ <a href="#workspace" class="start choice_btn">START</a>
352
+ <a href="#examples" class="view_examples choice_btn">View examples</a>
353
+ </div>
354
+ </div>
355
+ <div class="title_half">
356
+ <img src="https://buyanghc.github.io/head.jpg" alt="">
357
+ </div>
358
+ </div>
359
+
360
+ <div class="examples" id="examples">
361
+ <div class="head">
362
+ <h2>EXAMPLES</h2>
363
+ </div>
364
+ <p>Click to run the example !</p>
365
+ <div class="img_box">
366
+ <div class="eg">
367
+ <a href="#step2" id="eg1"><img src="https://buyanghc.github.io/eg1.jpg" alt=""></a>
368
+ <p>· WhatsApp</p>
369
+ </div>
370
+ <div class="eg">
371
+ <a href="#step2" id="eg2"><img src="https://buyanghc.github.io/eg2.jpg" alt=""></a>
372
+ <p>· Snap</p>
373
+ </div>
374
+ <div class="eg">
375
+ <a href="#step2" id="eg3"><img src="https://buyanghc.github.io/eg3.jpg" alt=""></a>
376
+ <p>· Mcdonald's</p>
377
+ </div>
378
+ </div>
379
+ </div>
380
+
381
+ <div class="workspace" id="workspace">
382
+ <div class="head">
383
+ <h2>WORKSPACE</h2>
384
+ <div class="workspace_btn">
385
+ <input class="btn run" type="submit" value="RUN">
386
+ <button class="btn reset">RESET</button>
387
+ </div>
388
+ </div>
389
+
390
+ <div class="space">
391
+ <div class="step1">
392
+ <label for="inputBox">Step 1 : Input privacy policy URL</label>
393
+ <input class="url" type="text" id="inputBox" name="inputBox" placeholder="Privacy Policy URL Link" />
394
+ </div>
395
+
396
+ <div class="step2" id="step2">
397
+ <div class="img">
398
+ <label for="image-input">Step 2 : Upload the screenshot</label>
399
+ """)
400
+
401
+ gr.Image(type="pil", label="Screenshot Upload", elem_id="image_input").style(container=False)
402
+
403
+ gr.HTML("""
404
+ </div>
405
+ <div class="point"><img src="https://buyanghc.github.io/point.png" alt=""></div>
406
+ <div class="img">
407
+ <label>Outcome :</label>
408
+ <div class="phone" id="output">
409
+ <img src="" alt="" id="result">
410
+ <div class="left next_btn"></div>
411
+ <div class="right next_btn"></div>
412
+ </div>
413
+ </div>
414
+ </div>
415
+ </div>
416
+ </div>
417
+ """)
418
+
419
+ # 隐藏的gradio组件
420
  eg_btn1 = gr.Button("Example 1", elem_id="example1", visible=False)
421
  eg_btn2 = gr.Button("Example 2", elem_id="example2", visible=False)
422
  eg_btn3 = gr.Button("Example 3", elem_id="example3", visible=False)
 
521
  threading.Thread(target=schedule_monitoring, args=(12,)).start() # monitor resources using per 12 hours
522
 
523
  try:
524
+ demo.launch(css=css)
525
  logger.info('Gradio app launched successfully')
526
  except Exception as e:
527
  logger.error('Error occurred while launching Gradio app', exc_info=True)
web_page.css CHANGED
@@ -5,9 +5,9 @@ body{
5
  min-height: 100vh;
6
  background-color: white; /* Set the background color to white */
7
  overflow-x: hidden; /* Hide the horizontal overflow (scrollbar only in the vertical direction) */
8
- display: flex;
9
- flex-direction: column; /* 按列布局 */
10
- align-items: center;
11
  color: rgb(40, 40, 40);
12
  }
13
 
@@ -31,19 +31,19 @@ body{
31
  display: flex;
32
  flex-direction: column; /* 按列布局 */
33
  justify-content: center; /* 垂直方向居中 */
34
- padding-left: 120px;
35
- padding-right: 120px;
36
- box-sizing: border-box;
37
  }
38
 
39
  .title_half p{
40
- font-size: 22px;
 
41
  font-weight: bolder;
42
- margin-top: -10px;
43
  }
44
 
45
  h1{
46
- font-size: 80px;
47
  font-weight: bolder;
48
  }
49
 
@@ -51,7 +51,7 @@ h1{
51
  display: flex;
52
  width: 100%;
53
  height: 80px;
54
- margin-top: 50px;
55
  }
56
 
57
  .choice_btn{
@@ -67,26 +67,29 @@ h1{
67
 
68
  .start{
69
  background-color: rgb(40, 40, 40);
70
- color: white;
71
  margin-right: 20px;
72
- text-decoration: none;
73
  }
74
 
75
  .start:hover{
76
- background-color: rgb(117, 209, 255);
77
  }
78
 
79
  .view_examples{
80
- color: rgb(40, 40, 40);
81
  }
82
 
83
  .view_examples:hover{
84
- color: rgb(24, 157, 246);
85
  }
86
 
87
  .examples{
88
- width: 84%;
89
- margin-top: 80px;
 
 
 
90
  }
91
 
92
  .head{
@@ -96,15 +99,15 @@ h1{
96
  }
97
 
98
  h2{
99
- font-size: 47px;
100
  font-weight: bolder;
101
  }
102
 
103
  .examples p{
104
- font-size: 18px;
105
  font-weight: bolder;
106
- margin-top: -10px;
107
- margin-bottom: 50px;
108
  }
109
 
110
  .img_box{
@@ -119,7 +122,7 @@ h2{
119
  .eg img{
120
  width: 100%;
121
  height: auto;
122
- border: 3px solid rgb(188, 204, 212);
123
  transition: border-color 0.5s ease, border-width 0.5s ease;
124
  border-radius: 10px;
125
  cursor: pointer;
@@ -143,8 +146,11 @@ h2{
143
 
144
 
145
  .workspace{
146
- width: 84%;
147
  margin-top: 80px;
 
 
 
148
  margin-bottom: 180px;
149
  display: flex;
150
  flex-direction: column; /* 按列布局 */
@@ -163,19 +169,19 @@ h2{
163
  height: 45px;
164
  border: 2px solid rgb(40, 40, 40);
165
  transition: border-color 0.3s ease, color 0.3s ease, background-color 0.3s ease;
166
- border-radius: 2px;
167
  cursor: pointer;
168
  }
169
 
170
  .run{
171
- color: white;
172
- background-color: rgb(40, 40, 40);
173
  }
174
 
175
  .btn:hover{
176
- color: white;
177
- background-color: rgb(117, 209, 255);
178
- border: white;
179
  }
180
 
181
  .space{
@@ -185,23 +191,24 @@ h2{
185
  label{
186
  font-size: 18px;
187
  font-weight: bolder;
 
188
  }
189
 
190
  .step1{
191
  display: flex;
192
  flex-direction: column; /* 按列布局 */
193
- margin-top: 30px;
194
  }
195
 
196
  .url{
197
  height: 50px;
198
- margin-top: 20px;
199
- margin-bottom: 100px;
200
  font-size: 20px;
201
  color: rgb(194, 194, 194);
202
  padding-left: 10px;
203
  border: 2px solid rgb(40, 40, 40);
204
- border-radius: 5px;
205
  }
206
 
207
  .step2{
@@ -233,5 +240,13 @@ label{
233
  height: 750px;
234
  border: 2px solid rgb(40, 40, 40);
235
  border-radius: 5px;
236
- margin-top: 20px;
 
 
 
 
 
 
 
 
237
  }
 
5
  min-height: 100vh;
6
  background-color: white; /* Set the background color to white */
7
  overflow-x: hidden; /* Hide the horizontal overflow (scrollbar only in the vertical direction) */
8
+ display: flex !important;
9
+ flex-direction: column !important; /* 按列布局 */
10
+ align-items: center !important;
11
  color: rgb(40, 40, 40);
12
  }
13
 
 
31
  display: flex;
32
  flex-direction: column; /* 按列布局 */
33
  justify-content: center; /* 垂直方向居中 */
34
+ padding-left: 120px !important;
35
+ padding-right: 120px !important;
36
+ box-sizing: border-box !important;
37
  }
38
 
39
  .title_half p{
40
+ font-size: 21px !important;
41
+ margin-top: 10px;
42
  font-weight: bolder;
 
43
  }
44
 
45
  h1{
46
+ font-size: 80px !important;
47
  font-weight: bolder;
48
  }
49
 
 
51
  display: flex;
52
  width: 100%;
53
  height: 80px;
54
+ margin-top: 50px !important;
55
  }
56
 
57
  .choice_btn{
 
67
 
68
  .start{
69
  background-color: rgb(40, 40, 40);
70
+ color: white !important;
71
  margin-right: 20px;
72
+ text-decoration: none !important;
73
  }
74
 
75
  .start:hover{
76
+ background-color: rgb(117, 209, 255) !important;
77
  }
78
 
79
  .view_examples{
80
+ color: rgb(40, 40, 40) !important;
81
  }
82
 
83
  .view_examples:hover{
84
+ color: rgb(24, 157, 246) !important;
85
  }
86
 
87
  .examples{
88
+ width: 100%;
89
+ margin-top: 60px;
90
+ padding-left: 120px;
91
+ padding-right: 120px;
92
+ box-sizing: border-box;
93
  }
94
 
95
  .head{
 
99
  }
100
 
101
  h2{
102
+ font-size: 47px !important;
103
  font-weight: bolder;
104
  }
105
 
106
  .examples p{
107
+ font-size: 18px !important;
108
  font-weight: bolder;
109
+ margin-top: 20px;
110
+ margin-bottom: 40px !important;
111
  }
112
 
113
  .img_box{
 
122
  .eg img{
123
  width: 100%;
124
  height: auto;
125
+ border: 3px solid rgb(255, 255, 255);
126
  transition: border-color 0.5s ease, border-width 0.5s ease;
127
  border-radius: 10px;
128
  cursor: pointer;
 
146
 
147
 
148
  .workspace{
149
+ width: 100%;
150
  margin-top: 80px;
151
+ padding-left: 120px;
152
+ padding-right: 120px;
153
+ box-sizing: border-box;
154
  margin-bottom: 180px;
155
  display: flex;
156
  flex-direction: column; /* 按列布局 */
 
169
  height: 45px;
170
  border: 2px solid rgb(40, 40, 40);
171
  transition: border-color 0.3s ease, color 0.3s ease, background-color 0.3s ease;
172
+ border-radius: 5px;
173
  cursor: pointer;
174
  }
175
 
176
  .run{
177
+ color: white !important;
178
+ background-color: rgb(40, 40, 40) !important;
179
  }
180
 
181
  .btn:hover{
182
+ color: white !important;
183
+ background-color: rgb(117, 209, 255) !important;
184
+ border: white !important;
185
  }
186
 
187
  .space{
 
191
  label{
192
  font-size: 18px;
193
  font-weight: bolder;
194
+ margin-bottom: 10px;
195
  }
196
 
197
  .step1{
198
  display: flex;
199
  flex-direction: column; /* 按列布局 */
200
+ margin-top: 50px;
201
  }
202
 
203
  .url{
204
  height: 50px;
205
+ margin-top: 20px !important;
206
+ margin-bottom: 100px !important;
207
  font-size: 20px;
208
  color: rgb(194, 194, 194);
209
  padding-left: 10px;
210
  border: 2px solid rgb(40, 40, 40);
211
+ border-radius: 5px !important;
212
  }
213
 
214
  .step2{
 
240
  height: 750px;
241
  border: 2px solid rgb(40, 40, 40);
242
  border-radius: 5px;
243
+ margin-top: 20px !important;
244
+ }
245
+
246
+ #image_input{
247
+ width: 100%;
248
+ height: 750px;
249
+ border: 2px solid rgb(40, 40, 40);
250
+ border-radius: 5px;
251
+ margin-top: 20px !important;
252
  }
web_page.html CHANGED
@@ -4,252 +4,6 @@
4
  <meta charset="UTF-8">
5
  <title>Cpp4App Test</title>
6
  <!-- <link rel="stylesheet" type="text/css" href="https://buyanghc.github.io/web_page.css">-->
7
- <style>
8
- body{
9
- margin: 0; /* Remove the default margin */
10
- padding: 0;
11
- min-width: 100vw; /* Set the body's minimum width and height to the window's width and height */
12
- min-height: 100vh;
13
- background-color: white; /* Set the background color to white */
14
- overflow-x: hidden; /* Hide the horizontal overflow (scrollbar only in the vertical direction) */
15
- display: flex !important;
16
- flex-direction: column !important; /* 按列布局 */
17
- align-items: center !important;
18
- color: rgb(40, 40, 40);
19
- }
20
-
21
- .title{
22
- width: 100%;
23
- height: 485px;
24
- display: flex;
25
- }
26
-
27
- .title_half{
28
- width: 50%;
29
- height: 100%;
30
- }
31
-
32
- .title_half img{
33
- width: 100%;
34
- height: auto;
35
- }
36
-
37
- .title_content{
38
- display: flex;
39
- flex-direction: column; /* 按列布局 */
40
- justify-content: center; /* 垂直方向居中 */
41
- padding-left: 120px !important;
42
- padding-right: 120px !important;
43
- box-sizing: border-box !important;
44
- }
45
-
46
- .title_half p{
47
- font-size: 21px !important;
48
- margin-top: 10px;
49
- font-weight: bolder;
50
- }
51
-
52
- h1{
53
- font-size: 80px !important;
54
- font-weight: bolder;
55
- }
56
-
57
- .choice{
58
- display: flex;
59
- width: 100%;
60
- height: 80px;
61
- margin-top: 50px !important;
62
- }
63
-
64
- .choice_btn{
65
- width: 150px;
66
- height: 50px;
67
- display: flex;
68
- flex-direction: column; /* 按列布局 */
69
- justify-content: center; /* 垂直方向居中 */
70
- align-items: center;
71
- border-radius: 5px;
72
- transition: color 0.3s ease, background-color 0.3s ease;
73
- }
74
-
75
- .start{
76
- background-color: rgb(40, 40, 40);
77
- color: white !important;
78
- margin-right: 20px;
79
- text-decoration: none !important;
80
- }
81
-
82
- .start:hover{
83
- background-color: rgb(117, 209, 255) !important;
84
- }
85
-
86
- .view_examples{
87
- color: rgb(40, 40, 40) !important;
88
- }
89
-
90
- .view_examples:hover{
91
- color: rgb(24, 157, 246) !important;
92
- }
93
-
94
- .examples{
95
- width: 100%;
96
- margin-top: 60px;
97
- padding-left: 120px;
98
- padding-right: 120px;
99
- box-sizing: border-box;
100
- }
101
-
102
- .head{
103
- width: 100%;
104
- display: flex;
105
- justify-content: space-between;
106
- }
107
-
108
- h2{
109
- font-size: 47px !important;
110
- font-weight: bolder;
111
- }
112
-
113
- .examples p{
114
- font-size: 18px !important;
115
- font-weight: bolder;
116
- margin-top: 20px;
117
- margin-bottom: 40px !important;
118
- }
119
-
120
- .img_box{
121
- display: flex;
122
- justify-content: space-between;
123
- }
124
-
125
- .eg{
126
- width: 25%;
127
- }
128
-
129
- .eg img{
130
- width: 100%;
131
- height: auto;
132
- border: 3px solid rgb(255, 255, 255);
133
- transition: border-color 0.5s ease, border-width 0.5s ease;
134
- border-radius: 10px;
135
- cursor: pointer;
136
- }
137
-
138
- .eg img:hover{
139
- border-color: rgb(117, 209, 255); /* 悬停时边框颜色 */
140
- border-width: 3px; /* 悬停时边框粗细 */
141
- }
142
-
143
- .eg p{
144
- width: 100%;
145
- height: 60px;
146
- display: flex;
147
- flex-direction: column; /* 按列布局 */
148
- justify-content: center; /* 垂直方向居中 */
149
- align-items: center;
150
- margin: 0;
151
- font-style: italic;
152
- }
153
-
154
-
155
- .workspace{
156
- width: 100%;
157
- margin-top: 80px;
158
- padding-left: 120px;
159
- padding-right: 120px;
160
- box-sizing: border-box;
161
- margin-bottom: 180px;
162
- display: flex;
163
- flex-direction: column; /* 按列布局 */
164
- align-items: center;
165
- }
166
-
167
- .workspace_btn{
168
- width: 350px;
169
- display: flex;
170
- justify-content: space-between; /* 垂直方向居中 */
171
- align-items: center;
172
- }
173
-
174
- .btn{
175
- width: 150px;
176
- height: 45px;
177
- border: 2px solid rgb(40, 40, 40);
178
- transition: border-color 0.3s ease, color 0.3s ease, background-color 0.3s ease;
179
- border-radius: 5px;
180
- cursor: pointer;
181
- }
182
-
183
- .run{
184
- color: white !important;
185
- background-color: rgb(40, 40, 40) !important;
186
- }
187
-
188
- .btn:hover{
189
- color: white !important;
190
- background-color: rgb(117, 209, 255) !important;
191
- border: white !important;
192
- }
193
-
194
- .space{
195
- width: 80%;
196
- }
197
-
198
- label{
199
- font-size: 18px;
200
- font-weight: bolder;
201
- margin-bottom: 10px;
202
- }
203
-
204
- .step1{
205
- display: flex;
206
- flex-direction: column; /* 按列布局 */
207
- margin-top: 50px;
208
- }
209
-
210
- .url{
211
- height: 50px;
212
- margin-top: 20px !important;
213
- margin-bottom: 100px !important;
214
- font-size: 20px;
215
- color: rgb(194, 194, 194);
216
- padding-left: 10px;
217
- border: 2px solid rgb(40, 40, 40);
218
- border-radius: 5px !important;
219
- }
220
-
221
- .step2{
222
- display: flex;
223
- justify-content: space-between;
224
- }
225
-
226
- .img{
227
- display: flex;
228
- flex-direction: column; /* 按列布局 */
229
- width: 40%;
230
- }
231
-
232
- .point{
233
- width: 18%;
234
- display: flex;
235
- flex-direction: column; /* 按列布局 */
236
- justify-content: center;
237
- align-items: center;
238
- }
239
-
240
- .point img{
241
- width: 80%;
242
- height: auto;
243
- }
244
-
245
- .phone{
246
- width: 100%;
247
- height: 750px;
248
- border: 2px solid rgb(40, 40, 40);
249
- border-radius: 5px;
250
- margin-top: 20px !important;
251
- }
252
- </style>
253
  </head>
254
  <body>
255
 
@@ -322,52 +76,52 @@
322
  </div>
323
 
324
  <script>
325
- window.onload = function() {
326
- // 监听示例图片的点击事件
327
- document.querySelectorAll('.eg a').forEach(function(element) {
328
- element.addEventListener('click', function(event) {
329
- event.preventDefault(); // 阻止默认的锚点跳转行为
330
-
331
- // 获取点击的链接的ID
332
- const id = element.id;
333
-
334
- // 根据链接的ID选择运行不同的Gradio函数
335
- if (id === "eg1") {
336
- gradioApp().querySelector('button[gr-button-id="example1"]').click();
337
- } else if (id === "eg2") {
338
- gradioApp().querySelector('button[gr-button-id="example2"]').click();
339
- } else if (id === "eg3") {
340
- gradioApp().querySelector('button[gr-button-id="example3"]').click();
341
- }
342
-
343
- // 执行锚点跳转,保页面滚动到对应位置
344
- const target = document.querySelector(element.getAttribute('href'));
345
- if (target) {
346
- target.scrollIntoView({ behavior: "smooth" });
347
- }
348
- });
349
- });
350
-
351
-
352
- document.addEventListener('DOMContentLoaded', function() {
353
- // 创建一个MutationObserver来监视Gradio组件的变化
354
- const targetNode = gradioApp().querySelector('img[elem_id="image_output"]');
355
-
356
- if (targetNode) {
357
- const observer = new MutationObserver(function(mutationsList, observer) {
358
- for (const mutation of mutationsList) {
359
- if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
360
- // 获取Gradio组件的src属性并设置到HTML img标签中
361
- const newSrc = targetNode.getAttribute('src');
362
- document.getElementById('result').src = newSrc;
363
- }
364
- }
365
- });
366
-
367
- // 开始观察Gradio组件的src属性变化
368
- observer.observe(targetNode, { attributes: true });
369
- }
370
- });
371
 
372
 
373
  // // 绑定 "RUN" 按钮到 Gradio 的 submit_button
@@ -420,7 +174,7 @@
420
  // reader.readAsDataURL(file);
421
  // }
422
  // });
423
- };
424
  </script>
425
 
426
  </body>
 
4
  <meta charset="UTF-8">
5
  <title>Cpp4App Test</title>
6
  <!-- <link rel="stylesheet" type="text/css" href="https://buyanghc.github.io/web_page.css">-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  </head>
8
  <body>
9
 
 
76
  </div>
77
 
78
  <script>
79
+ // window.onload = function() {
80
+ // // 监听示例图片的点击事件
81
+ // document.querySelectorAll('.eg a').forEach(function(element) {
82
+ // element.addEventListener('click', function(event) {
83
+ // event.preventDefault(); // 阻止默认的锚点跳转行为
84
+ //
85
+ // // 获取点击的链接的ID
86
+ // const id = element.id;
87
+ //
88
+ // // 根据链接的ID选择运行不同的Gradio函数
89
+ // if (id === "eg1") {
90
+ // gradioApp().querySelector('button[gr-button-id="example1"]').click();
91
+ // } else if (id === "eg2") {
92
+ // gradioApp().querySelector('button[gr-button-id="example2"]').click();
93
+ // } else if (id === "eg3") {
94
+ // gradioApp().querySelector('button[gr-button-id="example3"]').click();
95
+ // }
96
+ //
97
+ // // 执行锚点跳转,���保页面滚动到对应位置
98
+ // const target = document.querySelector(element.getAttribute('href'));
99
+ // if (target) {
100
+ // target.scrollIntoView({ behavior: "smooth" });
101
+ // }
102
+ // });
103
+ // });
104
+ //
105
+ //
106
+ // document.addEventListener('DOMContentLoaded', function() {
107
+ // // 创建一个MutationObserver来监视Gradio组件的变化
108
+ // const targetNode = gradioApp().querySelector('img[elem_id="image_output"]');
109
+ //
110
+ // if (targetNode) {
111
+ // const observer = new MutationObserver(function(mutationsList, observer) {
112
+ // for (const mutation of mutationsList) {
113
+ // if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
114
+ // // 获取Gradio组件的src属性并设置到HTML img标签中
115
+ // const newSrc = targetNode.getAttribute('src');
116
+ // document.getElementById('result').src = newSrc;
117
+ // }
118
+ // }
119
+ // });
120
+ //
121
+ // // 开始观察Gradio组件的src属性变化
122
+ // observer.observe(targetNode, { attributes: true });
123
+ // }
124
+ // });
125
 
126
 
127
  // // 绑定 "RUN" 按钮到 Gradio 的 submit_button
 
174
  // reader.readAsDataURL(file);
175
  // }
176
  // });
177
+ // };
178
  </script>
179
 
180
  </body>