nick-leland commited on
Commit
ff36ed6
·
1 Parent(s): cfc47f2

Finalized the toy description

Browse files
Files changed (1) hide show
  1. app.py +8 -11
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 zoom(x, y):
130
  return x**2 + y**2
131
 
132
- def rotation(x, y):
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 == "Zoom":
145
- func = zoom
146
- elif func_choice == "Rotation":
147
- func = rotation
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(["Bulge", "Spiral", "Zoom", "Rotation"], 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,10 +172,7 @@ demo = gr.Interface(
172
  gr.Image(label="Gradient Vector Field")
173
  ],
174
  title="Image Transformation Demo!",
175
- description="This is a demo of the tool that I will be using to generate images to train a machine learning model on! This tool allows you to play around with the simple bulge effect primarily, I will be attempting to impliment manual function input within the app next!"
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)