-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
414298a
commit ba24ff6
Showing
7 changed files
with
445 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import streamlit as st | ||
from PIL import Image, ImageEnhance | ||
import cv2 | ||
import numpy as np | ||
|
||
def apply_augmentations(images, augmentations) -> list: | ||
new_images = [] | ||
for details, image in images: | ||
new_image = image | ||
if augmentations["resize"]["width"] is not None and augmentations["resize"]["height"] is not None: | ||
new_image = new_image.resize((augmentations["resize"]["width"], augmentations["resize"]["height"]), Image.ANTIALIAS) | ||
if augmentations["grayscale"] == True: | ||
new_image = new_image.convert('L') | ||
if augmentations["contrast"]["value"] is not None: | ||
new_image = ImageEnhance.Contrast(new_image).enhance(augmentations["contrast"]["value"]) | ||
if augmentations["brightness"]["value"] is not None: | ||
new_image = ImageEnhance.Brightness(new_image).enhance(augmentations["brightness"]["value"]) | ||
if augmentations["sharpness"]["value"] is not None: | ||
new_image = ImageEnhance.Sharpness(new_image).enhance(augmentations["sharpness"]["value"]) | ||
if augmentations["color"]["value"] is not None: | ||
new_image = ImageEnhance.Color(new_image).enhance(augmentations["color"]["value"]) | ||
if augmentations["denoise"] == True: | ||
if len(new_image.split()) != 3: | ||
new_image = Image.fromarray(cv2.fastNlMeansDenoising(np.array(new_image))) | ||
else: | ||
new_image = Image.fromarray(cv2.fastNlMeansDenoisingColored(np.array(new_image))) | ||
new_images.append((details, new_image)) | ||
return new_images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
""" | ||
A file with the high level image eda app functions | ||
""" | ||
import streamlit as st | ||
from helper_functions import * | ||
from image_eda.preparation import show_grid, show_sizes, show_histograms, show_channels, augmentations, export_images | ||
|
||
|
||
def image_data_app(): | ||
|
||
st.write("Welcome to the DQW for unsupervised image data. ", | ||
"Understanding your data is an important step ", | ||
"in AI model development. This app ", | ||
"offers visualisation of descriptive statistics of a ", | ||
"collection of images using a multitude of packages.") | ||
|
||
display_app_header(main_txt = "Step 1", | ||
sub_txt= "Upload data", | ||
is_sidebar=True) | ||
|
||
images = load_images() | ||
|
||
if images: | ||
|
||
display_app_header(main_txt = "Step 2", | ||
sub_txt= "Choose what you want to see/do", | ||
is_sidebar=True) | ||
|
||
selected_structure = st.sidebar.radio( | ||
"", | ||
("Image grid", | ||
"Image sizes", | ||
"Color histograms", | ||
"Color channels", | ||
"Augmentations")) | ||
|
||
if selected_structure == "Image grid": | ||
show_grid(images) | ||
elif selected_structure == "Image sizes": | ||
show_sizes(images) | ||
elif selected_structure == "Color histograms": | ||
show_histograms(images) | ||
elif selected_structure == "Color channels": | ||
show_channels(images) | ||
elif selected_structure == "Augmentations": | ||
augmentations(images) | ||
|
||
display_app_header(main_txt = "Step 3", | ||
sub_txt= "Export augmented data", | ||
is_sidebar=True) | ||
|
||
is_export = st.sidebar.button("Export ⬇️") | ||
if is_export: | ||
export_images(images) | ||
|
||
|
||
|
||
# prompt the user with an option to select which data they want to | ||
# analyse - save code, right now we only have 1 option | ||
#selected_structure = st.selectbox("Choose data structure to analyse", | ||
#("Unsupervised image data", | ||
#"Supervised image data, Classification", | ||
#"Supervised image data, Segmentation", | ||
#"Supervised image data, Regression")) | ||
|
||
#elif selected_structure == "Supervised image data, Classification": | ||
#st.error("This feature has not been implemented yet!") | ||
#elif selected_structure == "Supervised image data, Segmentation": | ||
#st.error("This feature has not been implemented yet!") | ||
#elif selected_structure == "Supervised image data, Regression": | ||
#st.error("This feature has not been implemented yet!") |
Oops, something went wrong.