Slender commited on
Commit
b084bff
·
1 Parent(s): 80ffe6b

second-commit

Browse files
Files changed (2) hide show
  1. app.py +46 -8
  2. requirements.txt +3 -1
app.py CHANGED
@@ -1,11 +1,49 @@
 
1
  import streamlit as st
2
- import pandas as pd
 
3
 
4
- st.title('A Simple Streamlit Web App')
5
- name = st.text_input('Enter your name', '')
6
- st.write(f'Hello {name}!')
7
 
8
- x = st.slider('Select an integer x', 0, 10, 1)
9
- y = st.slider('Select an integer y', 0, 10, 1)
10
- df = pd.DataFrame({'x': [x], 'y': [y] , 'x + y': [x + y]}, index=['addition row'])
11
- st.write(df)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
  import streamlit as st
3
+ import numpy as np
4
+ from PIL import Image
5
 
 
 
 
6
 
7
+ def brighten_image(image, amount):
8
+ img_bright = cv2.convertScaleAbs(image, beta=amount)
9
+ return img_bright
10
+
11
+
12
+ def blur_image(image, amount):
13
+ blur_img = cv2.GaussianBlur(image, (11, 11), amount)
14
+ return blur_img
15
+
16
+
17
+ def enhance_details(img):
18
+ hdr = cv2.detailEnhance(img, sigma_s=12, sigma_r=0.15)
19
+ return hdr
20
+
21
+
22
+ def main_loop():
23
+ st.title("OpenCV Demo App")
24
+ st.subheader("This app allows you to play with Image filters!")
25
+ st.text("We use OpenCV and Streamlit for this demo")
26
+
27
+ blur_rate = st.sidebar.slider("Blurring", min_value=0.5, max_value=3.5)
28
+ brightness_amount = st.sidebar.slider("Brightness", min_value=-50, max_value=50, value=0)
29
+ apply_enhancement_filter = st.sidebar.checkbox('Enhance Details')
30
+
31
+ image_file = st.file_uploader("Upload Your Image", type=['jpg', 'png', 'jpeg'])
32
+ if not image_file:
33
+ return None
34
+
35
+ original_image = Image.open(image_file)
36
+ original_image = np.array(original_image)
37
+
38
+ processed_image = blur_image(original_image, blur_rate)
39
+ processed_image = brighten_image(processed_image, brightness_amount)
40
+
41
+ if apply_enhancement_filter:
42
+ processed_image = enhance_details(processed_image)
43
+
44
+ st.text("Original Image vs Processed Image")
45
+ st.image([original_image, processed_image])
46
+
47
+
48
+ if __name__ == '__main__':
49
+ main_loop()
requirements.txt CHANGED
@@ -1 +1,3 @@
1
- streamlit==1.10.0
 
 
 
1
+ streamlit==1.10.0
2
+ opencv-python==4.6.0.66
3
+ Pillow==9.1.1