mirror of
https://github.com/artegoser/image-pluser-webui.git
synced 2024-11-23 20:36:20 +03:00
feat: full app
This commit is contained in:
parent
92a560c170
commit
f338f7b5c9
10 changed files with 171 additions and 0 deletions
43
README.md
Normal file
43
README.md
Normal file
|
@ -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.
|
98
app.py
Normal file
98
app.py
Normal file
|
@ -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()
|
BIN
imgs/examples/denoise.png
Normal file
BIN
imgs/examples/denoise.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
BIN
imgs/examples/startracks.png
Normal file
BIN
imgs/examples/startracks.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 787 KiB |
BIN
imgs/examples/ui.png
Normal file
BIN
imgs/examples/ui.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
gradio==3.27.0
|
||||||
|
Pillow==9.5.0
|
||||||
|
tqdm==4.65.0
|
7
scripts/one-click/install.bat
Normal file
7
scripts/one-click/install.bat
Normal file
|
@ -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
|
7
scripts/win/install.bat
Normal file
7
scripts/win/install.bat
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
cd ../../
|
||||||
|
|
||||||
|
python -m venv venv
|
||||||
|
call ./venv/Scripts/activate.bat
|
||||||
|
pip install -r requirements.txt
|
6
scripts/win/start.bat
Normal file
6
scripts/win/start.bat
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
cd ../../
|
||||||
|
|
||||||
|
call ./venv/Scripts/activate.bat
|
||||||
|
python app.py
|
7
scripts/win/update.bat
Normal file
7
scripts/win/update.bat
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
cd ../../
|
||||||
|
|
||||||
|
git pull
|
||||||
|
call ./venv/Scripts/activate.bat
|
||||||
|
pip install -r requirements.txt
|
Loading…
Add table
Reference in a new issue