File size: 6,169 Bytes
a76fcef
605da91
6158815
50695f9
1a1bdb2
 
732b864
a76fcef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
605da91
a76fcef
 
 
 
 
 
 
605da91
a76fcef
 
6158815
 
 
 
 
 
 
 
 
 
 
50695f9
 
 
 
 
 
 
 
 
6158815
 
 
 
50695f9
6158815
 
1a1bdb2
732b864
1a1bdb2
732b864
 
 
 
 
 
 
5dd27e3
 
 
732b864
 
 
 
 
 
 
 
 
 
 
807c35c
 
732b864
 
4d7c5a6
50695f9
1a1bdb2
50695f9
1a1bdb2
50695f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2adc529
50695f9
 
 
2adc529
4d7c5a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84a1b4f
 
4d7c5a6
 
732b864
6158815
 
a76fcef
 
 
 
 
 
 
 
6158815
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import os
import torch
import gradio as gr
from video_watermark_remover import *
from video_converter import *
from image_converter import *
from image_watermark_remover import *
from typing import List
from pydantic import BaseModel
from lama_cleaner.server import main

class FakeLamaArgs(BaseModel):
    host: str = "0.0.0.0"
    port: int = 5000
    model: str = 'lama'
    hf_access_token: str = ""
    sd_disable_nsfw: bool = False
    sd_cpu_textencoder: bool = True
    sd_run_local: bool = False
    sd_enable_xformers: bool = False
    local_files_only: bool = False
    cpu_offload: bool = False
    device: str = "cuda" if torch.cuda.is_available() else "cpu"
    gui: bool = False
    gui_size: List[int] = [1000, 1000]
    input: str = ''
    disable_model_switch: bool = True
    debug: bool = False
    no_half: bool = False
    disable_nsfw: bool = False
    enable_xformers: bool = True if torch.cuda.is_available() else False
    model_dir: str = None
    output_dir: str = None

css = """
    #remove_btn {
        background: linear-gradient(#201d18, #2bbbc3);
        font-weight: bold;
        font-size: 18px;
        color:white;
    }
    #remove_btn:hover {
        background: linear-gradient(#2bbbc3, #201d18);
    }
    #convert_btn {
        background: linear-gradient(#201d18, #2bbbc3);
        font-weight: bold;
        font-size: 18px;
        color:white;
    }
    #convert_btn:hover {
        background: linear-gradient(#2bbbc3, #201d18);
    }
    footer {
        display: none !important;
    }
"""

demo = gr.Blocks(css=css, title="Video Watermark Remover")
with demo:
    with gr.Tab("Image Converter"):
        gr.Markdown("""
        # <center>πŸ–ΌοΈ Image Converter</center>
        """)
        image_format = ['jpg', 'jpeg', 'png', 'bmp', 'tiff', 'gif', 'webp', 'ico', 'heic', 'heiv', 'heif']
        with gr.Row():
            with gr.Column():
                input_image = gr.File(label="Upload an Image")
            with gr.Column():
                with gr.Row():
                    image_format = gr.Radio(image_format, label="Select Format", interactive=False)
                with gr.Row():
                    image_convert_btn = gr.Button("Convert Image", interactive=False, elem_id="convert_btn")
        with gr.Row():
            output_image = gr.File(label="Output File", interactive=False)
        image_status = gr.Textbox(label="Status", interactive=False)
        input_image.change(lambda x: gr.Radio.update(interactive=True), inputs=[input_image], outputs=[image_format])
        image_format.change(lambda x: gr.Button.update(interactive=True), None, outputs=[image_convert_btn])
        image_convert_btn.click(convert_image, inputs=[input_image, image_format], outputs=[output_image, image_status])

    with gr.Tab("Image Watermark Remover"):
        gr.Markdown("""
        # <center>πŸ–ΌοΈ Image Watermark Remover</center>
        """)
        input_image_watermark = gr.Image(label="Upload an Image", tool="sketch", type="pil", interactive=True)
        image_remove_btn = gr.Button("Remove Watermark", interactive=True, elem_id="remove_btn")
        output_image_clean = gr.Image(label="Output Image", interactive=True)

        image_remove_btn.click(remove_image_watermark, inputs=[input_image_watermark], outputs=[output_image_clean])

    with gr.Tab("Video Converter"):
        gr.Markdown("""
        # <center>πŸŽ₯ Video Converter</center>
        """)
        video_format = ['webm', 'wmv', 'mkv', 'mp4', 'avi', 'mpeg', 'vob', 'flv']
        audio_format = ['mp3', 'wav', 'ogg', 'flac', 'aac']
        with gr.Row():
            with gr.Column():
                input_video = gr.Video(label="Upload a Video")
            with gr.Column():
                with gr.Row():
                    format_select = gr.Radio(["Video", "Audio"], label="Select Format", default="Video")
                with gr.Row():
                    format = gr.Radio(video_format, label="Select Format", interactive=False)
        with gr.Row():
            with gr.Column():
                pass
            with gr.Column():
                convert_btn = gr.Button("Convert Video", interactive=False, elem_id="convert_btn")
            with gr.Column():
                pass
        with gr.Row():
            output = gr.File(label="Output File", interactive=False)
        status = gr.Textbox(label="Status", interactive=False)
        format_select.change(lambda x: gr.Radio.update(choices=video_format if x == "Video" else audio_format, interactive=True), inputs=[format_select], outputs=[format])
        format.change(lambda x: gr.Button.update(interactive=True), None, outputs=[convert_btn])
        convert_btn.click(convert_video, inputs=[input_video, format], outputs=[output, status])
        
    with gr.Tab("Video Watermark Remover"):
        gr.Markdown("""
        # <center>πŸŽ₯ Video Watermark Remover (Slow)</center>
        """)
        with gr.Row():
            with gr.Column():
                input_video = gr.Video(label="Upload a Video")
            with gr.Column():
                mask = gr.Image(label="Create a mask for the image", tool="sketch", type="pil", interactive=False)
        with gr.Row():
            with gr.Column():
                pass
            with gr.Column():
                remove_btn = gr.Button("Remove Watermark", interactive=False, elem_id="remove_btn")
            with gr.Column():
                pass
        
        with gr.Row():
            output_video = gr.File(label="Output Video", interactive=False)
        input_video.change(convert_video_to_frames, inputs=[input_video], outputs=[mask, remove_btn])
        remove_btn.click(remove_watermark, inputs=[mask], outputs=[output_video, remove_btn])
    
    gr.Markdown("""## <center style="margin:20px;">Developed by Muhammad Ahmed<img src="https://avatars.githubusercontent.com/u/63394104?v=4" style="height:50px;width:50px;border-radius:50%;margin:5px;"></img></center>
    """)

# Change the code according to the error
import threading

thread = threading.Thread(target=main, kwargs={'args': FakeLamaArgs()})
thread.daemon = True
thread.start()

demo.launch(show_api=False)