Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -28,6 +28,10 @@ CHECKPOINT_GEN = HF_FILENAME
|
|
28 |
MODEL = None
|
29 |
MODEL_LOAD_ERROR = None
|
30 |
DOWNLOADED_CHECKPOINT_PATH = None # Store the path after download
|
|
|
|
|
|
|
|
|
31 |
|
32 |
print(f"Attempting to download/load model '{HF_FILENAME}' from repo '{HF_REPO_ID}' onto device '{DEVICE}'...")
|
33 |
|
@@ -168,11 +172,23 @@ def download_and_clear(url):
|
|
168 |
raise gr.Error(f"An unexpected error occurred preparing the image: {e}")
|
169 |
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
# --- Gradio Blocks Interface Definition ---
|
172 |
print("Setting up Gradio Blocks interface...")
|
173 |
|
174 |
with gr.Blocks() as demo:
|
175 |
saved_image_path = gr.State()
|
|
|
176 |
gr.Markdown(f"""
|
177 |
# Watermark Remover
|
178 |
|
|
|
28 |
MODEL = None
|
29 |
MODEL_LOAD_ERROR = None
|
30 |
DOWNLOADED_CHECKPOINT_PATH = None # Store the path after download
|
31 |
+
image_paths = ["1.png", "2.png", "3.png", "4.png", "5.png", "6.png", "7.png"]
|
32 |
+
images = [Image.open(path) for path in image_paths]
|
33 |
+
N = len(images)
|
34 |
+
|
35 |
|
36 |
print(f"Attempting to download/load model '{HF_FILENAME}' from repo '{HF_REPO_ID}' onto device '{DEVICE}'...")
|
37 |
|
|
|
172 |
raise gr.Error(f"An unexpected error occurred preparing the image: {e}")
|
173 |
|
174 |
|
175 |
+
def show_image(index):
|
176 |
+
index = index % N
|
177 |
+
return images[index], index
|
178 |
+
|
179 |
+
def next_img(index):
|
180 |
+
return show_image(index + 1)
|
181 |
+
|
182 |
+
def prev_img(index):
|
183 |
+
return show_image(index - 1)
|
184 |
+
|
185 |
+
|
186 |
# --- Gradio Blocks Interface Definition ---
|
187 |
print("Setting up Gradio Blocks interface...")
|
188 |
|
189 |
with gr.Blocks() as demo:
|
190 |
saved_image_path = gr.State()
|
191 |
+
index_state = gr.State(0)
|
192 |
gr.Markdown(f"""
|
193 |
# Watermark Remover
|
194 |
|