Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ import gradio as gr
|
|
6 |
|
7 |
sb_logo = Image.open("./SB_logo_horizontal.png")
|
8 |
|
9 |
-
def freemium_watermark(img, sb_logo):
|
10 |
width_px, height_px = img.size
|
11 |
# Convert the logo to "RGBA" mode and resize it to 80% of the image width
|
12 |
sb_logo = sb_logo.convert("RGBA")
|
@@ -16,7 +16,7 @@ def freemium_watermark(img, sb_logo):
|
|
16 |
sb_logo = sb_logo.resize((new_logo_width, new_logo_height))
|
17 |
# Make the logo semi-translucent
|
18 |
transparent_img = Image.new('RGBA', (sb_logo.width, sb_logo.height), (0, 0, 0, 0)) # Create a transparent image of the same size
|
19 |
-
sb_logo = Image.blend(transparent_img, sb_logo, alpha=
|
20 |
# Calculate the position to paste the logo at the center of the image
|
21 |
paste_x_position = (width_px - new_logo_width) // 2
|
22 |
paste_y_position = int(height_px * 0.4) - (new_logo_height // 2)
|
@@ -37,7 +37,8 @@ def lighter(input_path):
|
|
37 |
dilated_edges = cv2.dilate(edges, structuring_element, iterations=2)
|
38 |
line_drawing = 255 - dilated_edges
|
39 |
line_img = Image.fromarray(line_drawing)
|
40 |
-
|
|
|
41 |
|
42 |
def darker(input_path):
|
43 |
print('darker')
|
@@ -54,7 +55,8 @@ def darker(input_path):
|
|
54 |
dilated_edges = cv2.dilate(edges, structuring_element, iterations=2)
|
55 |
line_drawing = 255 - dilated_edges
|
56 |
line_img = Image.fromarray(line_drawing)
|
57 |
-
|
|
|
58 |
|
59 |
with gr.Blocks(analytics_enabled=False, theme=gr.themes.Soft()) as demo:
|
60 |
with gr.Row():
|
@@ -67,6 +69,7 @@ with gr.Blocks(analytics_enabled=False, theme=gr.themes.Soft()) as demo:
|
|
67 |
with gr.Row():
|
68 |
lighter_btn=gr.Button("Lighter")
|
69 |
darker_btn=gr.Button("Darker")
|
|
|
70 |
gr.Markdown("<p style='text-align: center; font-size: 20px;'>Want to remove the watermark?</p>\n")
|
71 |
gr.Markdown("<p style='text-align: center; font-size: 20px;'>Subscribe or <a href='https://skyebrowse.com/pricing'>purchase a model</a> starting at $3.<p>")
|
72 |
lighter_btn.click(lighter, inputs=[input], outputs=[output], show_progress="minimal")
|
@@ -84,6 +87,7 @@ with gr.Blocks(analytics_enabled=False, theme=gr.themes.Soft()) as demo:
|
|
84 |
dilated_edges = cv2.dilate(edges, structuring_element, iterations=2)
|
85 |
line_drawing = 255 - dilated_edges
|
86 |
line_img = Image.fromarray(line_drawing)
|
87 |
-
|
|
|
88 |
|
89 |
demo.queue(default_concurrency_limit=10, api_open=False).launch(show_api=False)
|
|
|
6 |
|
7 |
sb_logo = Image.open("./SB_logo_horizontal.png")
|
8 |
|
9 |
+
def freemium_watermark(img, sb_logo, alpha):
|
10 |
width_px, height_px = img.size
|
11 |
# Convert the logo to "RGBA" mode and resize it to 80% of the image width
|
12 |
sb_logo = sb_logo.convert("RGBA")
|
|
|
16 |
sb_logo = sb_logo.resize((new_logo_width, new_logo_height))
|
17 |
# Make the logo semi-translucent
|
18 |
transparent_img = Image.new('RGBA', (sb_logo.width, sb_logo.height), (0, 0, 0, 0)) # Create a transparent image of the same size
|
19 |
+
sb_logo = Image.blend(transparent_img, sb_logo, alpha=alpha) # Blend the logo with the transparent image
|
20 |
# Calculate the position to paste the logo at the center of the image
|
21 |
paste_x_position = (width_px - new_logo_width) // 2
|
22 |
paste_y_position = int(height_px * 0.4) - (new_logo_height // 2)
|
|
|
37 |
dilated_edges = cv2.dilate(edges, structuring_element, iterations=2)
|
38 |
line_drawing = 255 - dilated_edges
|
39 |
line_img = Image.fromarray(line_drawing)
|
40 |
+
alpha = 0.3
|
41 |
+
return freemium_watermark(line_img, sb_logo, alpha)
|
42 |
|
43 |
def darker(input_path):
|
44 |
print('darker')
|
|
|
55 |
dilated_edges = cv2.dilate(edges, structuring_element, iterations=2)
|
56 |
line_drawing = 255 - dilated_edges
|
57 |
line_img = Image.fromarray(line_drawing)
|
58 |
+
alpha = 0.5
|
59 |
+
return freemium_watermark(line_img, sb_logo, alpha)
|
60 |
|
61 |
with gr.Blocks(analytics_enabled=False, theme=gr.themes.Soft()) as demo:
|
62 |
with gr.Row():
|
|
|
69 |
with gr.Row():
|
70 |
lighter_btn=gr.Button("Lighter")
|
71 |
darker_btn=gr.Button("Darker")
|
72 |
+
|
73 |
gr.Markdown("<p style='text-align: center; font-size: 20px;'>Want to remove the watermark?</p>\n")
|
74 |
gr.Markdown("<p style='text-align: center; font-size: 20px;'>Subscribe or <a href='https://skyebrowse.com/pricing'>purchase a model</a> starting at $3.<p>")
|
75 |
lighter_btn.click(lighter, inputs=[input], outputs=[output], show_progress="minimal")
|
|
|
87 |
dilated_edges = cv2.dilate(edges, structuring_element, iterations=2)
|
88 |
line_drawing = 255 - dilated_edges
|
89 |
line_img = Image.fromarray(line_drawing)
|
90 |
+
alpha = 0.3
|
91 |
+
return freemium_watermark(line_img, sb_logo, alpha)
|
92 |
|
93 |
demo.queue(default_concurrency_limit=10, api_open=False).launch(show_api=False)
|