lime-j commited on
Commit
e114461
·
1 Parent(s): 23ecf58
Files changed (3) hide show
  1. __pycache__/db.cpython-310.pyc +0 -0
  2. app.py +4 -3
  3. app.pyi +74 -45
__pycache__/db.cpython-310.pyc CHANGED
Binary files a/__pycache__/db.cpython-310.pyc and b/__pycache__/db.cpython-310.pyc differ
 
app.py CHANGED
@@ -76,9 +76,9 @@ with gr.Blocks() as block_demo:
76
  print(time.time())
77
  random.seed(time.time())
78
  image = random.choice(image_list)
79
- method1, method2 = '', ''
80
- while method1 == method2:
81
- method1, method2 = random.sample(methods, 2)
82
  # method1_suffix, method2_suffix =
83
  image1 = bucket + '/' + method1 + '/' + image
84
  image2 = bucket + '/' + method2 + '/' + image
@@ -93,6 +93,7 @@ with gr.Blocks() as block_demo:
93
  image, method1, method2, image1, image2, property, image_input = refresh_comparison()
94
  return image1, image2, f"<h2 style='font-size: 24px;'>Which one <mark class='red'>{property_dict[property]}</mark>?</h2>",\
95
  image, method1, method2, property, image_input
 
96
  def on_load(request: gr.Request):
97
 
98
  headers = request.headers
 
76
  print(time.time())
77
  random.seed(time.time())
78
  image = random.choice(image_list)
79
+ # method1, method2 = '', ''
80
+ # while method1 == method2:
81
+ method1, method2 = random.sample(methods, 2)
82
  # method1_suffix, method2_suffix =
83
  image1 = bucket + '/' + method1 + '/' + image
84
  image2 = bucket + '/' + method2 + '/' + image
 
93
  image, method1, method2, image1, image2, property, image_input = refresh_comparison()
94
  return image1, image2, f"<h2 style='font-size: 24px;'>Which one <mark class='red'>{property_dict[property]}</mark>?</h2>",\
95
  image, method1, method2, property, image_input
96
+
97
  def on_load(request: gr.Request):
98
 
99
  headers = request.headers
app.pyi CHANGED
@@ -3,26 +3,54 @@ from functools import partial
3
  import random
4
  import os
5
  from db import send_message_to_mongodb
6
- all_property = ['artifact', 'color', 'noise', 'lightness', 'blury']
7
  property_dict = {
8
- 'artifact': 'less artifact',
9
- 'color': 'pleasant color',
10
- 'noise': 'less noise',
11
- 'lightness': 'Illuminated',
12
- 'blury': 'sharp boundary'
13
  }
14
- methods = ['IMGS_bread', 'IMGS_iat', 'retinexformer_png', 'images', 'IMGS_Kind', 'IMGS_ZeroDCE', 'IMGS_nerco']
 
 
15
  method_dict = {
16
- 'IMGS_bread': 'Bread',
17
  'IMGS_iat': 'IAT',
18
  'retinexformer_png': 'Retinexformer',
19
  'images': 'Original Input',
20
  'IMGS_Kind': 'Kind',
21
  'IMGS_ZeroDCE': 'ZeroDCE',
22
- 'IMGS_nerco': 'NeRCo'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
  core_file = './file_list.txt'
25
- bucket = os.getenv('bucket') #'https://checkpoints.mingjia.li/Exdark/'
26
  image_list = []
27
  with open(core_file, 'r') as f:
28
  for line in f:
@@ -50,6 +78,7 @@ with gr.Blocks() as block_demo:
50
  random.seed(time.time())
51
  image = random.choice(image_list)
52
  method1, method2 = random.sample(methods, 2)
 
53
  image1 = bucket + '/' + method1 + '/' + image
54
  image2 = bucket + '/' + method2 + '/' + image
55
  image_input = bucket + '/images/' + image
@@ -58,29 +87,34 @@ with gr.Blocks() as block_demo:
58
 
59
  def refresh_comparison():
60
  return get_random_comparison()
 
 
 
 
 
61
  def on_load(request: gr.Request):
 
62
  headers = request.headers
63
  host = request.client.host
64
  request_state = dict(headers)
65
  request_state['host'] = host
66
- # print(str(request))
67
- print(request_state)
68
- image, method1, method2, image1, image2, property, image_input = refresh_comparison()
69
- return image1, image2, f'### Which one is better in terms of **{property_dict[property]}**?',\
70
- image, method1, method2, property, image_input, request_state
 
 
71
  with gr.Row():
72
  with gr.Column():
73
- gr.Markdown("<h2 style='font-size: 24px;'>Low-light Image Enhancer Arena 🥊</h2>")
74
- gr.Markdown("<p style='font-size: 18px;'>This is a simple arena to test the performance of different low-light image enhancers.</p>")
75
- gr.Markdown("<p style='font-size: 18px;'>Please help us to find the better image!</p>")
76
- gr.Markdown("<p style='font-size: 18px;'>Failures:</p>")
77
- gr.Markdown("<ul style='font-size: 18px;'>"
78
- f"<li><strong>Artifact:</strong> - There might be unwanted or unintended alterations in the image.</li>"
79
- f"<li><strong>Color Degradation:</strong> - The color recoverd from low-light input is not the same as the color in the input image.</li>"
80
- f"<li><strong>Noise:</strong> - There might be noise in the image.</li>"
81
- f"<li><strong>Poor Illumination:</strong> - The brightness level of the image is not good, it might be too dark or too bright.</li>"
82
- f"<li><strong>Blury:</strong> - The sharpness of the image is not good, it might be too blurry or too sharp.</li>"
83
  "</ul>")
 
84
  img_input = gr.Image(label="Input Image")
85
 
86
 
@@ -93,41 +127,36 @@ with gr.Blocks() as block_demo:
93
  block_demo.load(on_load, inputs=[], outputs=[img1, img2, prop_text,
94
  image_state, method1_state, method2_state, property_state, img_input, ip_state])
95
  with gr.Row():
96
- l_butt = gr.Button("Left is better")
97
- r_butt = gr.Button("Right is better")
98
  with gr.Row():
99
  both_good = gr.Button("Both are good")
100
  both_bad = gr.Button("Both are bad")
101
 
102
  result = gr.Markdown("")
103
- lnote, rnote = gr.Markdown(""), gr.Markdown("")
104
  refresh_butt = gr.Button("Next one", visible=False, interactive=False)
105
  # good, bad = gr.State('both_good'), gr.State('both_bad')
106
  def update_interface(choice, image, method1, method2, property, ip):
107
  # if type(choice) is not str : choice = choice.value
108
  print(choice, image, method1, method2, property, ip)
109
  send_message_to_mongodb(image, property, method1, method2, choice, ip)
 
110
  # new_image, new_method1, new_method2, new_image1, new_image2, new_property = get_random_comparison()
111
  return [
112
- # gr.Markdown("### Thanks for your submission!"),
113
- gr.Button(interactive=False),
114
- gr.Button(interactive=False),
115
- gr.Button(interactive=False),
116
- gr.Button(interactive=False),
117
- # gr.Markdown(f'Left image: {method_dict[method1]}'),
118
- # gr.Markdown(f'Right image: {method_dict[method2]}'),
119
- gr.Button(visible=True, interactive=True),
120
- # gr.Image(new_image1),
121
- # gr.Image(new_image2),
122
- # f'### Submit your choice for **{new_property}**'
123
  ]
124
 
125
- l_butt.click(fn=update_interface, inputs=[method1_state, image_state, method1_state, method2_state, property_state, ip_state], outputs=[l_butt, r_butt, both_good, both_bad, refresh_butt])
126
- r_butt.click(fn=update_interface, inputs=[method2_state, image_state, method1_state, method2_state, property_state, ip_state], outputs=[l_butt, r_butt, both_good, both_bad, refresh_butt])
127
- both_good.click(fn=update_interface, inputs=[gr.State('both_good'), image_state, method1_state, method2_state, property_state, ip_state], outputs=[l_butt, r_butt, both_good, both_bad, refresh_butt])
128
- both_bad.click(fn=update_interface, inputs=[gr.State('both_bad'), image_state, method1_state, method2_state, property_state, ip_state], outputs=[l_butt, r_butt, both_good, both_bad, refresh_butt])
129
-
 
 
 
 
130
 
131
- refresh_butt.click(None, js="window.location.reload()")
132
 
133
  block_demo.launch()
 
3
  import random
4
  import os
5
  from db import send_message_to_mongodb
6
+ all_property = ['artifact', 'color', 'lightness', 'blury', 'overall']
7
  property_dict = {
8
+ 'artifact': 'has less artifact or noise',
9
+ 'color': 'has more pleasant color',
10
+ 'lightness': 'is well illuminated',
11
+ 'blury': 'has sharp and clear texture',
12
+ 'overall': 'is more visually plansant'
13
  }
14
+ methods = ['IMGS_Bread', 'IMGS_iat', 'retinexformer_png', 'images', 'IMGS_Kind',
15
+ 'IMGS_ZeroDCE', 'IMGS_nerco', 'IMGS_quadprior', 'IMGS_LIME', 'IMGS_pairlie',
16
+ 'IMGS_LD', 'IMGS_llflow', 'IMGS_sci', 'IMGS_pydiff', 'IMGS_snr'] # add 4x prob for new methods
17
  method_dict = {
18
+ 'IMGS_Bread': 'Bread',
19
  'IMGS_iat': 'IAT',
20
  'retinexformer_png': 'Retinexformer',
21
  'images': 'Original Input',
22
  'IMGS_Kind': 'Kind',
23
  'IMGS_ZeroDCE': 'ZeroDCE',
24
+ 'IMGS_nerco': 'NeRCo',
25
+ 'IMGS_quadprior' : 'QuadPrior',
26
+ 'IMGS_LIME' : 'LIME',
27
+ 'IMGS_pairlie': 'PairLIE',
28
+ 'IMGS_LD' : 'LightenDiffusion',
29
+ 'IMGS_SCI' : 'SCI',
30
+ 'IMGS_pydiff' : 'PyDiff',
31
+ 'IMGS_LLFlow' : 'LLFlow',
32
+ 'IMGS_snr' : 'SNR'
33
+ }
34
+
35
+ method_file_dict = {
36
+ 'IMGS_Bread': 'png',
37
+ 'IMGS_iat': 'jpg',
38
+ 'retinexformer_png': 'png',
39
+ 'images': 'ori',
40
+ 'IMGS_Kind': 'ori',
41
+ 'IMGS_ZeroDCE': 'ori',
42
+ 'IMGS_nerco': 'png',
43
+ 'IMGS_quadprior' : 'png',
44
+ 'IMGS_LIME' : 'png',
45
+ 'IMGS_pairlie': 'png',
46
+ 'IMGS_LD' : 'jpg',
47
+ 'IMGS_SCI' : 'png',
48
+ 'IMGS_pydiff' : 'png',
49
+ 'IMGS_LLFlow' : 'png'
50
+
51
  }
52
  core_file = './file_list.txt'
53
+ bucket = os.getenv('bucket')
54
  image_list = []
55
  with open(core_file, 'r') as f:
56
  for line in f:
 
78
  random.seed(time.time())
79
  image = random.choice(image_list)
80
  method1, method2 = random.sample(methods, 2)
81
+ # method1_suffix, method2_suffix =
82
  image1 = bucket + '/' + method1 + '/' + image
83
  image2 = bucket + '/' + method2 + '/' + image
84
  image_input = bucket + '/images/' + image
 
87
 
88
  def refresh_comparison():
89
  return get_random_comparison()
90
+
91
+ def prepare_everything_else():
92
+ image, method1, method2, image1, image2, property, image_input = refresh_comparison()
93
+ return image1, image2, f"<h2 style='font-size: 24px;'>Which one <mark class='red'>{property_dict[property]}</mark>?</h2>",\
94
+ image, method1, method2, property, image_input
95
  def on_load(request: gr.Request):
96
+
97
  headers = request.headers
98
  host = request.client.host
99
  request_state = dict(headers)
100
  request_state['host'] = host
101
+
102
+ return *prepare_everything_else(), request_state
103
+
104
+ gr.Markdown("<h2 align='center',style='font-size: 24px;'>Low-light Image Enhancer Arena 🥊</h2>")
105
+ gr.Markdown("<p align='center', style='font-size: 18px;'>LIME-Eval is an arena to ask human-beings to judge the performance of different low-light image enhancers with respect to </p>")
106
+ gr.Markdown("<p align='center', style='font-size: 18px;'>different factors, including Artifact, Color Degradation, Noise, Poor Illumination, Blur, and Overall quality.</p>")
107
+ # gr.Markdown("<p align='center', style='font-size: 18px;'>Please help us to find the better image!</p>")
108
  with gr.Row():
109
  with gr.Column():
110
+ gr.Markdown("<p style='font-size: 16px;'>Common Factors:</p>")
111
+ gr.Markdown("<ul style='font-size: 14px;'>"
112
+ f"<li><strong>Artifact/Noise:</strong> - There might be unintended alterations in the image.</li>"
113
+ f"<li><strong>Unpleasant Color:</strong> - The color recovered from low-light input can be unnatural.</li>"
114
+ f"<li><strong>Poor Illumination:</strong> - The brightness of the image is unsatisfying, it might be too dark or too bright.</li>"
115
+ f"<li><strong>Blury/Oversmooth:</strong> - The texture of the image is unclear, possibly due to an overshooted denoising.</li>"
 
 
 
 
116
  "</ul>")
117
+ gr.Image('./cat.png', label='Example')
118
  img_input = gr.Image(label="Input Image")
119
 
120
 
 
127
  block_demo.load(on_load, inputs=[], outputs=[img1, img2, prop_text,
128
  image_state, method1_state, method2_state, property_state, img_input, ip_state])
129
  with gr.Row():
130
+ l_butt = gr.Button("Image 1")
131
+ r_butt = gr.Button("Image 2")
132
  with gr.Row():
133
  both_good = gr.Button("Both are good")
134
  both_bad = gr.Button("Both are bad")
135
 
136
  result = gr.Markdown("")
137
+ # l_note, r_note = gr.Markdown(""), gr.Markdown("")
138
  refresh_butt = gr.Button("Next one", visible=False, interactive=False)
139
  # good, bad = gr.State('both_good'), gr.State('both_bad')
140
  def update_interface(choice, image, method1, method2, property, ip):
141
  # if type(choice) is not str : choice = choice.value
142
  print(choice, image, method1, method2, property, ip)
143
  send_message_to_mongodb(image, property, method1, method2, choice, ip)
144
+ img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input = prepare_everything_else()
145
  # new_image, new_method1, new_method2, new_image1, new_image2, new_property = get_random_comparison()
146
  return [
147
+ img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip
 
 
 
 
 
 
 
 
 
 
148
  ]
149
 
150
+ l_butt.click(fn=update_interface, inputs=[method1_state, image_state, method1_state, method2_state, property_state, ip_state],
151
+ outputs=[img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip_state])
152
+ r_butt.click(fn=update_interface, inputs=[method2_state, image_state, method1_state, method2_state, property_state, ip_state],
153
+ outputs=[img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip_state])
154
+ both_good.click(fn=update_interface, inputs=[gr.State('both_good'), image_state, method1_state, method2_state, property_state, ip_state],
155
+ outputs=[img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip_state])
156
+ both_bad.click(fn=update_interface, inputs=[gr.State('both_bad'), image_state, method1_state, method2_state, property_state, ip_state],
157
+ outputs=[img1, img2, prop_text, image_state, method1_state, method2_state, property_state, img_input, ip_state])
158
+
159
 
160
+ # refresh_butt.click(None, js="window.location.reload()")
161
 
162
  block_demo.launch()