andy-wyx commited on
Commit
35d2da8
·
1 Parent(s): 503ec98

increase brightness of image shown

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -243,9 +243,20 @@ def preprocess_image(image, output_size=(300, 300)):
243
 
244
  return image_resized
245
 
 
 
 
 
 
 
 
 
 
 
 
246
  def update_display(image):
247
  original_image = image
248
- processed_image = preprocess_image(image)
249
  instruction = "Image ready. Please switch to the 'Specimen Workbench' tab to check out further analysis and outputs."
250
  model_name = "Fossils 142"
251
 
@@ -404,7 +415,7 @@ with gr.Blocks(theme='sudeepshouche/minimalist') as demo:
404
  # generate_exp.click(exp_image, inputs=[input_image,model_name,explain_method,sampling_size], outputs=[exp1,exp2,exp3,exp4,exp5]) #
405
  # with gr.Accordion('Closest Leaves Images'):
406
  # gr.Markdown("5 closest leaves")
407
- with gr.Accordion("Class Distribution of Closest Samples "):
408
  gr.Markdown("Visualize plant family distribution of top-k closest samples in our dataset")
409
  with gr.Column():
410
  with gr.Row():
 
243
 
244
  return image_resized
245
 
246
+ def increase_brightness(img, value=30):
247
+ hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # Convert to HSV
248
+ h, s, v = cv2.split(hsv)
249
+
250
+ lim = 255 - value
251
+ v[v > lim] = 255
252
+ v[v <= lim] += value
253
+
254
+ final_hsv = cv2.merge((h, s, v))
255
+ img_bright = cv2.cvtColor(final_hsv, cv2.COLOR_HSV2BGR)
256
+ return img_bright
257
  def update_display(image):
258
  original_image = image
259
+ processed_image = preprocess_image(increase_brightness(image,value=50))
260
  instruction = "Image ready. Please switch to the 'Specimen Workbench' tab to check out further analysis and outputs."
261
  model_name = "Fossils 142"
262
 
 
415
  # generate_exp.click(exp_image, inputs=[input_image,model_name,explain_method,sampling_size], outputs=[exp1,exp2,exp3,exp4,exp5]) #
416
  # with gr.Accordion('Closest Leaves Images'):
417
  # gr.Markdown("5 closest leaves")
418
+ with gr.Accordion("Family Distribution of Closest Samples "):
419
  gr.Markdown("Visualize plant family distribution of top-k closest samples in our dataset")
420
  with gr.Column():
421
  with gr.Row():