Spaces:
Build error
Build error
Upload app.py
Browse files
app.py
CHANGED
|
@@ -9,11 +9,12 @@ import streamlit as st
|
|
| 9 |
import os
|
| 10 |
import random
|
| 11 |
import pandas as pd
|
| 12 |
-
from PIL import Image
|
| 13 |
import numpy as np
|
| 14 |
import gspread
|
| 15 |
from oauth2client.service_account import ServiceAccountCredentials
|
| 16 |
|
|
|
|
| 17 |
# -------------------------
|
| 18 |
# Global parameters
|
| 19 |
# -------------------------
|
|
@@ -36,18 +37,23 @@ def load_image_pair(index):
|
|
| 36 |
|
| 37 |
def form_callback(name, imgID, correct):
|
| 38 |
with open(RESULTS_FILE, 'a+') as f: #Append & read mode
|
| 39 |
-
|
| 40 |
# st.success(f"{name},{imgID},{correct}\n")
|
| 41 |
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
#
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# -------------------------
|
| 53 |
# Navigation via st.session_state
|
|
@@ -170,6 +176,7 @@ if st.session_state.page == "evaluation":
|
|
| 170 |
img2 = Image.open(pair[1][1])
|
| 171 |
img2 = img2.convert("L")
|
| 172 |
|
|
|
|
| 173 |
|
| 174 |
# Affichage dans deux colonnes avec radio buttons sous chacune
|
| 175 |
col1, col2 = st.columns(2)
|
|
|
|
| 9 |
import os
|
| 10 |
import random
|
| 11 |
import pandas as pd
|
| 12 |
+
from PIL import Image, ImageEnhance
|
| 13 |
import numpy as np
|
| 14 |
import gspread
|
| 15 |
from oauth2client.service_account import ServiceAccountCredentials
|
| 16 |
|
| 17 |
+
|
| 18 |
# -------------------------
|
| 19 |
# Global parameters
|
| 20 |
# -------------------------
|
|
|
|
| 37 |
|
| 38 |
def form_callback(name, imgID, correct):
|
| 39 |
with open(RESULTS_FILE, 'a+') as f: #Append & read mode
|
| 40 |
+
f.write(f"{name},{imgID},{correct}\n")
|
| 41 |
# st.success(f"{name},{imgID},{correct}\n")
|
| 42 |
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def match_brightness(source_img, target_img):
|
| 46 |
+
source_brightness = np.mean(np.array(source_img))
|
| 47 |
+
target_brightness = np.mean(np.array(target_img))
|
| 48 |
+
|
| 49 |
+
if target_brightness == 0:
|
| 50 |
+
factor = 1 # avoid division by zero
|
| 51 |
+
else:
|
| 52 |
+
factor = source_brightness / target_brightness
|
| 53 |
+
|
| 54 |
+
enhancer = ImageEnhance.Brightness(target_img)
|
| 55 |
+
adjusted = enhancer.enhance(factor)
|
| 56 |
+
return adjusted
|
| 57 |
|
| 58 |
# -------------------------
|
| 59 |
# Navigation via st.session_state
|
|
|
|
| 176 |
img2 = Image.open(pair[1][1])
|
| 177 |
img2 = img2.convert("L")
|
| 178 |
|
| 179 |
+
img2 = match_brightness(img1, img2)
|
| 180 |
|
| 181 |
# Affichage dans deux colonnes avec radio buttons sous chacune
|
| 182 |
col1, col2 = st.columns(2)
|