mirror of
https://github.com/artegoser/image-pluser-webui.git
synced 2024-11-21 19:36:21 +03:00
feat: sharpen method
This commit is contained in:
parent
45916cd320
commit
8d9f2a8a17
3 changed files with 21 additions and 10 deletions
|
@ -7,3 +7,8 @@ def canny_edge(file_name):
|
||||||
image = image.convert("L")
|
image = image.convert("L")
|
||||||
|
|
||||||
return image.filter(ImageFilter.FIND_EDGES)
|
return image.filter(ImageFilter.FIND_EDGES)
|
||||||
|
|
||||||
|
|
||||||
|
def sharpen(file_name):
|
||||||
|
image = Image.open(file_name)
|
||||||
|
return image.filter(ImageFilter.SHARPEN)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import ffmpeg
|
import ffmpeg
|
||||||
import os
|
import os
|
||||||
from processing.utils import generate_name, get_date_text, generate_name_with_file_name
|
from processing.utils import generate_name, get_date_text, generate_name_with_file_name
|
||||||
from methods.bulk_methods import canny_edge
|
from methods.bulk_methods import canny_edge, sharpen
|
||||||
|
|
||||||
|
|
||||||
def images_to_video(directory, fps, img_ext, img_name_format, video_name, video_ext, video_dir):
|
def images_to_video(directory, fps, img_ext, img_name_format, video_name, video_ext, video_dir):
|
||||||
|
@ -29,11 +29,17 @@ def video_to_images(video_path, img_ext):
|
||||||
def bulk_processing(directory, out_directory, method):
|
def bulk_processing(directory, out_directory, method):
|
||||||
date = get_date_text()
|
date = get_date_text()
|
||||||
if method == "canny edge":
|
if method == "canny edge":
|
||||||
for file in os.listdir(directory):
|
run_bulk(canny_edge, directory, out_directory, date)
|
||||||
img = canny_edge(os.path.join(directory, file))
|
elif method == "sharpen":
|
||||||
if out_directory:
|
run_bulk(sharpen, directory, out_directory, date)
|
||||||
img_out_path = os.path.join(out_directory, file)
|
|
||||||
else:
|
|
||||||
img_out_path = generate_name_with_file_name(
|
def run_bulk(func, directory, out_directory, date):
|
||||||
name=file, subfolder=os.path.join("images", date))
|
for file in os.listdir(directory):
|
||||||
img.save(img_out_path)
|
img = func(os.path.join(directory, file))
|
||||||
|
if out_directory:
|
||||||
|
img_out_path = os.path.join(out_directory, file)
|
||||||
|
else:
|
||||||
|
img_out_path = generate_name_with_file_name(
|
||||||
|
name=file, subfolder=os.path.join("images", date))
|
||||||
|
img.save(img_out_path)
|
||||||
|
|
|
@ -9,7 +9,7 @@ with gr.Blocks() as app:
|
||||||
directory = gr.Text(
|
directory = gr.Text(
|
||||||
placeholder="A directory with many images.", lines=1, label="Directory")
|
placeholder="A directory with many images.", lines=1, label="Directory")
|
||||||
method = gr.Dropdown(
|
method = gr.Dropdown(
|
||||||
choices=["canny edge"], value="canny edge", label="Method")
|
choices=["canny edge", "sharpen"], value="canny edge", label="Method")
|
||||||
|
|
||||||
with gr.Accordion("Advanced settings", open=False) as acc:
|
with gr.Accordion("Advanced settings", open=False) as acc:
|
||||||
out_dir = gr.Text(
|
out_dir = gr.Text(
|
||||||
|
|
Loading…
Add table
Reference in a new issue