ledetele commited on
Commit
0d486bf
·
1 Parent(s): 2d0131e

Update pages/03_B&W_Images_Colorizer.py

Browse files
Files changed (1) hide show
  1. pages/03_B&W_Images_Colorizer.py +13 -13
pages/03_B&W_Images_Colorizer.py CHANGED
@@ -10,36 +10,36 @@ from utils import colorize_image, change_model, load_lottieurl
10
 
11
  #st.set_page_config(page_title="Image & Video Colorizer", page_icon="🎨", layout="wide")
12
 
13
- st.title("B&W Images Colorizer")
14
 
15
 
16
  loaded_model = eccv16(pretrained=True).eval()
17
  current_model = "None"
18
 
19
  st.write("""
20
- ##### Input a black and white image and get a colorized version of it.
21
- ###### ➠ If you want to colorize multiple images just upload them all at once.
22
- ###### ➠ Uploading already colored images won't raise errors but images won't look good.""")
23
 
24
 
25
  def main():
26
  model = st.selectbox(
27
- "Select Model (Both models have their pros and cons, I recommend trying both and keeping the best for you task)",
28
  ["ECCV16", "SIGGRAPH17"], index=0)
29
 
30
  # Make the user select a model
31
  loaded_model = change_model(current_model, model)
32
- st.write(f"Model is now {model}")
33
 
34
  # Ask the user if he wants to see colorization
35
- display_results = st.checkbox('Display results in real time', value=True)
36
 
37
  # Input for the user to upload images
38
- uploaded_file = st.file_uploader("Upload your images here...", type=['jpg', 'png', 'jpeg'],
39
  accept_multiple_files=True)
40
 
41
  # If the user clicks on the button
42
- if st.button("Colorize"):
43
  # If the user uploaded images
44
  if uploaded_file is not None:
45
  if display_results:
@@ -59,7 +59,7 @@ def main():
59
  with col1:
60
  st.image(image, use_column_width="always")
61
  with col2:
62
- with st.spinner("Colorizing image..."):
63
  out_img, new_img = colorize_image(file, loaded_model)
64
  new_img.save("IMG_" + str(i+1) + ".jpg")
65
  st.image(out_img, use_column_width="always")
@@ -78,20 +78,20 @@ def main():
78
  with col2:
79
  # Provide the zip file data for download
80
  st.download_button(
81
- label="Download Colorized Images" if len(uploaded_file) > 1 else "Download Colorized Image",
82
  data=open(zip_filename, "rb").read(),
83
  file_name=zip_filename,
84
  )
85
  else:
86
  with col2:
87
  st.download_button(
88
- label="Download Colorized Image",
89
  data=open("IMG_1.jpg", "rb").read(),
90
  file_name="IMG_1.jpg",
91
  )
92
 
93
  else:
94
- st.warning('Upload a file', icon="⚠️")
95
 
96
 
97
  if __name__ == "__main__":
 
10
 
11
  #st.set_page_config(page_title="Image & Video Colorizer", page_icon="🎨", layout="wide")
12
 
13
+ st.title("黑白图像着色器")
14
 
15
 
16
  loaded_model = eccv16(pretrained=True).eval()
17
  current_model = "None"
18
 
19
  st.write("""
20
+ ##### 输入黑白图像并获得其彩色版本。
21
+ ###### ➠ 如果您想对多张图像进行着色,只需一次上传它们即可。
22
+ ###### ➠ 上传已经着色的图像不会引发错误,但图像看起来不太好。""")
23
 
24
 
25
  def main():
26
  model = st.selectbox(
27
+ "选择模型(两种模型都有其优点和缺点,我建议尝试两种模型并保持最适合您的任务)",
28
  ["ECCV16", "SIGGRAPH17"], index=0)
29
 
30
  # Make the user select a model
31
  loaded_model = change_model(current_model, model)
32
+ st.write(f"现在是 {model}")
33
 
34
  # Ask the user if he wants to see colorization
35
+ display_results = st.checkbox('实时显示结果', value=True)
36
 
37
  # Input for the user to upload images
38
+ uploaded_file = st.file_uploader("在这里上传您的图片...", type=['jpg', 'png', 'jpeg'],
39
  accept_multiple_files=True)
40
 
41
  # If the user clicks on the button
42
+ if st.button("着色"):
43
  # If the user uploaded images
44
  if uploaded_file is not None:
45
  if display_results:
 
59
  with col1:
60
  st.image(image, use_column_width="always")
61
  with col2:
62
+ with st.spinner("为图像着色..."):
63
  out_img, new_img = colorize_image(file, loaded_model)
64
  new_img.save("IMG_" + str(i+1) + ".jpg")
65
  st.image(out_img, use_column_width="always")
 
78
  with col2:
79
  # Provide the zip file data for download
80
  st.download_button(
81
+ label="下载彩色图像" if len(uploaded_file) > 1 else "下载彩色图像",
82
  data=open(zip_filename, "rb").read(),
83
  file_name=zip_filename,
84
  )
85
  else:
86
  with col2:
87
  st.download_button(
88
+ label="下载彩色图像",
89
  data=open("IMG_1.jpg", "rb").read(),
90
  file_name="IMG_1.jpg",
91
  )
92
 
93
  else:
94
+ st.warning('请上传文件', icon="⚠️")
95
 
96
 
97
  if __name__ == "__main__":