Spaces:
Build error
Build error
nick-leland
commited on
Commit
·
9f35487
1
Parent(s):
a395fc6
Updated the model output!
Browse files
app.py
CHANGED
@@ -154,7 +154,8 @@ print(f"NumPy version: {np.__version__}")
|
|
154 |
print(f"PyTorch version: {torch.__version__}")
|
155 |
print(f"FastAI version: {fastai.__version__}")
|
156 |
|
157 |
-
|
|
|
158 |
|
159 |
|
160 |
def transform_image(image, func_choice, randomization_check, radius, center_x, center_y, strength, reverse_gradient=True, spiral_frequency=1):
|
@@ -210,11 +211,13 @@ def transform_image(image, func_choice, randomization_check, radius, center_x, c
|
|
210 |
# Have to convert to image first
|
211 |
result = Image.fromarray(transformed)
|
212 |
|
213 |
-
|
214 |
-
|
215 |
-
print(
|
|
|
|
|
216 |
|
217 |
-
return transformed,
|
218 |
|
219 |
demo = gr.Interface(
|
220 |
fn=transform_image,
|
@@ -232,9 +235,10 @@ demo = gr.Interface(
|
|
232 |
],
|
233 |
outputs=[
|
234 |
gr.Image(label="Transformed Image"),
|
235 |
-
gr.Image(label="Gradient Vector Field"),
|
236 |
# gr.Image(label="Result", num_top_classes=2)
|
237 |
-
|
|
|
|
|
238 |
],
|
239 |
title="Image Transformation Demo!",
|
240 |
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 (;"
|
|
|
154 |
print(f"PyTorch version: {torch.__version__}")
|
155 |
print(f"FastAI version: {fastai.__version__}")
|
156 |
|
157 |
+
learn_bias = load_learner('model_bias.pkl')
|
158 |
+
learn_fresh = load_learner('model_fresh.pkl')
|
159 |
|
160 |
|
161 |
def transform_image(image, func_choice, randomization_check, radius, center_x, center_y, strength, reverse_gradient=True, spiral_frequency=1):
|
|
|
211 |
# Have to convert to image first
|
212 |
result = Image.fromarray(transformed)
|
213 |
|
214 |
+
result_bias = str(learn_bias.predict(result))
|
215 |
+
result_fresh = str(learn_fresh.predict(result))
|
216 |
+
print("Results")
|
217 |
+
print(result_bias)
|
218 |
+
print(result_fresh)
|
219 |
|
220 |
+
return transformed, result_bias, result_fresh, vector_field
|
221 |
|
222 |
demo = gr.Interface(
|
223 |
fn=transform_image,
|
|
|
235 |
],
|
236 |
outputs=[
|
237 |
gr.Image(label="Transformed Image"),
|
|
|
238 |
# gr.Image(label="Result", num_top_classes=2)
|
239 |
+
gr.Textbox(label='Result Bias'),
|
240 |
+
gr.Textbox(label='Result Fresh'),
|
241 |
+
gr.Image(label="Gradient Vector Field")
|
242 |
],
|
243 |
title="Image Transformation Demo!",
|
244 |
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 (;"
|