diff --git a/README.md b/README.md new file mode 100644 index 0000000..78b1496 --- /dev/null +++ b/README.md @@ -0,0 +1,43 @@ +# Image-Pluser WebUI Application + +Image-Pluser is a web user interface (WebUI) application built on top of Gradio that allows users to stack photos using different methods. The application provides a simple and intuitive interface for users to upload multiple images and combine them in various ways. + +## Getting Started + +To run Image-Pluser, follow these steps: + +1. Clone the repository: `git clone https://github.com/artegoser/image-pluser-webui.git` +2. Create venv: `python -m venv venv` +3. Install the necessary dependencies: `pip install -r requirements.txt` +4. Run the application: `python app.py` +5. Access the application by visiting http://localhost:7860/ in your web browser. + +### one-click-installers + +Just download and run the file in `scripts/one-click` (you need git and python3). + +# Available Methods + +1. Denoising: Removes noise from the image (pictures should not move) +2. StarTracks: Creates star tracks (the pictures should show the sky, which gradually moves) +3. Noise extractor: Gets all the noise in the image (actually makes nonsense) +4. Untrack: Removes stars from the sky (pictures are the same as in StarTracks) + +# Examples + +Denoise +![denoise](imgs/examples/denoise.png) + +StarTracks +![startracks](imgs/examples/startracks.png) + +Ui +![ui](imgs/examples/ui.png) + +# Contributing + +Contributions to Image-Pluser are welcome! If you would like to contribute, please fork the repository and submit a pull request. + +# License + +This project is licensed under the MIT License. See the `LICENSE` file for details. diff --git a/app.py b/app.py new file mode 100644 index 0000000..fbf0e24 --- /dev/null +++ b/app.py @@ -0,0 +1,98 @@ +import datetime +import gradio as gr +from PIL import Image, ImageChops +import os +from tqdm import tqdm + + +def impluser(dir, method): + + files = os.listdir(dir) + files = list(map(lambda x: os.path.join(dir, x), files)) + files = list(filter(lambda x: x.endswith(".png"), files)) + + if method == "denoise": + img = denoise(files) + elif method == "startracks": + img = startracks(files) + elif method == "noise extractor": + img = noise_extractor(files) + elif method == "untrack": + img = untrack(files) + + name = generate_name() + img.save(name) + + return [name] + + +def generate_name(): + # if not exists output create it + if not os.path.exists("./output"): + os.mkdir("./output") + + return f"./output/{datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.png" + + +def denoise(files): + bias = 1 + image = Image.open(files[0]) + for file in tqdm(files): + + alpha = 1/bias + + im2 = Image.open(file) + im3 = Image.blend(image, im2, alpha) + + image = im3 + + bias += 1 + + return image + + +def startracks(files): + image = Image.open(files[0]) + for file in tqdm(files): + im2 = Image.open(file) + im3 = ImageChops.lighter(image, im2) + image = im3 + + return image + + +def noise_extractor(files): + image = Image.open(files[0]) + for file in tqdm(files, unit=' images'): + im2 = Image.open(file) + im3 = ImageChops.difference(image, im2) + image = im3 + + return image + + +def untrack(files): + image = Image.open(files[0]) + for file in tqdm(files, unit=' images'): + im2 = Image.open(file) + im3 = ImageChops.darker(image, im2) + image = im3 + + return image + + +with gr.Blocks() as app: + with gr.Row(): + with gr.Column(): + directory = gr.Textbox( + placeholder="A directory on the same machine where the server is running.", lines=1, label="Directory") + methods = gr.Dropdown( + choices=["denoise", "startracks", "noise extractor", "untrack"], value="denoise", label="Method") + submit = gr.Button("Submit") + + with gr.Column(): + output = gr.Gallery() + + submit.click(impluser, inputs=[directory, methods], outputs=[output]) + +app.launch() diff --git a/imgs/examples/denoise.png b/imgs/examples/denoise.png new file mode 100644 index 0000000..e68429a Binary files /dev/null and b/imgs/examples/denoise.png differ diff --git a/imgs/examples/startracks.png b/imgs/examples/startracks.png new file mode 100644 index 0000000..c95a115 Binary files /dev/null and b/imgs/examples/startracks.png differ diff --git a/imgs/examples/ui.png b/imgs/examples/ui.png new file mode 100644 index 0000000..28c4ae2 Binary files /dev/null and b/imgs/examples/ui.png differ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..210ff6c --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +gradio==3.27.0 +Pillow==9.5.0 +tqdm==4.65.0 diff --git a/scripts/one-click/install.bat b/scripts/one-click/install.bat new file mode 100644 index 0000000..41da164 --- /dev/null +++ b/scripts/one-click/install.bat @@ -0,0 +1,7 @@ +@echo off + +git clone https://github.com/artegoser/image-pluser-webui.git +cd image-pluser-webui +python -m venv venv +call ./venv/Scripts/activate.bat +pip install -r requirements.txt \ No newline at end of file diff --git a/scripts/win/install.bat b/scripts/win/install.bat new file mode 100644 index 0000000..95814b8 --- /dev/null +++ b/scripts/win/install.bat @@ -0,0 +1,7 @@ +@echo off + +cd ../../ + +python -m venv venv +call ./venv/Scripts/activate.bat +pip install -r requirements.txt \ No newline at end of file diff --git a/scripts/win/start.bat b/scripts/win/start.bat new file mode 100644 index 0000000..720b6a1 --- /dev/null +++ b/scripts/win/start.bat @@ -0,0 +1,6 @@ +@echo off + +cd ../../ + +call ./venv/Scripts/activate.bat +python app.py \ No newline at end of file diff --git a/scripts/win/update.bat b/scripts/win/update.bat new file mode 100644 index 0000000..5c8db02 --- /dev/null +++ b/scripts/win/update.bat @@ -0,0 +1,7 @@ +@echo off + +cd ../../ + +git pull +call ./venv/Scripts/activate.bat +pip install -r requirements.txt \ No newline at end of file