Spaces:
Build error
Build error
nick-leland
commited on
Commit
·
ff36ed6
1
Parent(s):
cfc47f2
Finalized the toy description
Browse files
app.py
CHANGED
@@ -126,10 +126,10 @@ def create_gradient_vector_field(gx, gy, image_shape, step=20, reverse=False):
|
|
126 |
def transform_image(image, func_choice, radius, center_x, center_y, strength, edge_smoothness, reverse_gradient=True, spiral_frequency=1):
|
127 |
I = np.asarray(Image.open(image))
|
128 |
|
129 |
-
def
|
130 |
return x**2 + y**2
|
131 |
|
132 |
-
def
|
133 |
return np.arctan2(y, x)
|
134 |
|
135 |
def bulge(x, y):
|
@@ -141,10 +141,10 @@ def transform_image(image, func_choice, radius, center_x, center_y, strength, ed
|
|
141 |
theta = np.arctan2(y, x)
|
142 |
return r * np.sin(theta - frequency * r)
|
143 |
|
144 |
-
if func_choice == "
|
145 |
-
func =
|
146 |
-
elif func_choice == "
|
147 |
-
func =
|
148 |
elif func_choice == "Bulge":
|
149 |
func = bulge
|
150 |
elif func_choice == "Spiral":
|
@@ -159,7 +159,7 @@ demo = gr.Interface(
|
|
159 |
fn=transform_image,
|
160 |
inputs=[
|
161 |
gr.Image(type="filepath"),
|
162 |
-
gr.Dropdown(["
|
163 |
gr.Slider(0, 0.5, value=0.25, label="Radius (as fraction of image size)"),
|
164 |
gr.Slider(0, 1, value=0.5, label="Center X"),
|
165 |
gr.Slider(0, 1, value=0.5, label="Center Y"),
|
@@ -172,10 +172,7 @@ demo = gr.Interface(
|
|
172 |
gr.Image(label="Gradient Vector Field")
|
173 |
],
|
174 |
title="Image Transformation Demo!",
|
175 |
-
description="This is
|
176 |
)
|
177 |
|
178 |
-
def update_spiral_frequency(func_choice):
|
179 |
-
return gr.Slider(visible=(func_choice == "Spiral"))
|
180 |
-
|
181 |
demo.launch(share=True)
|
|
|
126 |
def transform_image(image, func_choice, radius, center_x, center_y, strength, edge_smoothness, reverse_gradient=True, spiral_frequency=1):
|
127 |
I = np.asarray(Image.open(image))
|
128 |
|
129 |
+
def pinch(x, y):
|
130 |
return x**2 + y**2
|
131 |
|
132 |
+
def shift(x, y):
|
133 |
return np.arctan2(y, x)
|
134 |
|
135 |
def bulge(x, y):
|
|
|
141 |
theta = np.arctan2(y, x)
|
142 |
return r * np.sin(theta - frequency * r)
|
143 |
|
144 |
+
if func_choice == "Pinch":
|
145 |
+
func = pinch
|
146 |
+
elif func_choice == "Shift":
|
147 |
+
func = shift
|
148 |
elif func_choice == "Bulge":
|
149 |
func = bulge
|
150 |
elif func_choice == "Spiral":
|
|
|
159 |
fn=transform_image,
|
160 |
inputs=[
|
161 |
gr.Image(type="filepath"),
|
162 |
+
gr.Dropdown(["Pinch", "Spiral", "Shift", "Bulge"], value="Bulge", label="Function"),
|
163 |
gr.Slider(0, 0.5, value=0.25, label="Radius (as fraction of image size)"),
|
164 |
gr.Slider(0, 1, value=0.5, label="Center X"),
|
165 |
gr.Slider(0, 1, value=0.5, label="Center Y"),
|
|
|
172 |
gr.Image(label="Gradient Vector Field")
|
173 |
],
|
174 |
title="Image Transformation Demo!",
|
175 |
+
description="This is the baseline function that will be used to generate the database for a machine learning model I am working on called 'DistortionMl'! The goal of this model is to detect and then reverse image transformations that can be generated here! You can read more about the project at this repository link : https://github.com/nick-leland/DistortionML. The main function that I was working on is the 'Bulge' function, I can't really guarantee that the others work well (;"
|
176 |
)
|
177 |
|
|
|
|
|
|
|
178 |
demo.launch(share=True)
|