Spaces:
Build error
Build error
Steven Limcorn
commited on
Commit
·
9eab909
1
Parent(s):
a86cb8b
Meged minecraft and regular upscaler playground, added x2 models.
Browse files- app.py +19 -6
- minecraft_examples/minecraft-1.jpg +0 -0
- minecraft_examples/minecraft-2.jpg +0 -0
- minecraft_examples/minecraft-3.jpg +0 -0
- minecraft_examples/minecraft-4.jpg +0 -0
- minecraft_examples/minecraft-5.jpg +0 -0
- models/minecraft_modelx4.ort +0 -0
- models/modelx2.ort +0 -0
- models/{model.ort → modelx4.ort} +0 -0
app.py
CHANGED
|
@@ -39,8 +39,8 @@ def convert_pil_to_cv2(image):
|
|
| 39 |
return open_cv_image
|
| 40 |
|
| 41 |
|
| 42 |
-
def upscale(image):
|
| 43 |
-
model_path = "models/model.ort"
|
| 44 |
img = convert_pil_to_cv2(image)
|
| 45 |
if img.ndim == 2:
|
| 46 |
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
|
|
@@ -62,16 +62,29 @@ def upscale(image):
|
|
| 62 |
return image_output
|
| 63 |
|
| 64 |
|
| 65 |
-
examples = [f"examples/example_{i+1}.png" for i in range(5)]
|
|
|
|
|
|
|
|
|
|
| 66 |
css = ".output-image, .input-image, .image-preview {height: 480px !important} "
|
|
|
|
| 67 |
|
| 68 |
gr.Interface(
|
| 69 |
fn=upscale,
|
| 70 |
-
inputs=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
outputs="image",
|
| 72 |
examples=examples,
|
|
|
|
| 73 |
title="Image Upscaling 🦆",
|
| 74 |
allow_flagging="never",
|
| 75 |
css=css,
|
| 76 |
-
).launch()
|
| 77 |
-
|
|
|
|
| 39 |
return open_cv_image
|
| 40 |
|
| 41 |
|
| 42 |
+
def upscale(image, model):
|
| 43 |
+
model_path = f"models/{model}.ort"
|
| 44 |
img = convert_pil_to_cv2(image)
|
| 45 |
if img.ndim == 2:
|
| 46 |
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
|
|
|
|
| 62 |
return image_output
|
| 63 |
|
| 64 |
|
| 65 |
+
examples = [[f"examples/example_{i+1}.png", "modelx4"] for i in range(5)]
|
| 66 |
+
examples += [
|
| 67 |
+
[f"minecraft_examples/minecraft-{j+1}.png", "minecraft_modelx4"] for j in range(5)
|
| 68 |
+
]
|
| 69 |
css = ".output-image, .input-image, .image-preview {height: 480px !important} "
|
| 70 |
+
model_choices = ["modelx2", "modelx4", "minecraft_modelx4"]
|
| 71 |
|
| 72 |
gr.Interface(
|
| 73 |
fn=upscale,
|
| 74 |
+
inputs=[
|
| 75 |
+
gr.inputs.Image(type="pil"),
|
| 76 |
+
gr.inputs.Radio(
|
| 77 |
+
model_choices,
|
| 78 |
+
type="value",
|
| 79 |
+
default=None,
|
| 80 |
+
label="Choose a Model",
|
| 81 |
+
optional=False,
|
| 82 |
+
),
|
| 83 |
+
],
|
| 84 |
outputs="image",
|
| 85 |
examples=examples,
|
| 86 |
+
examples_per_page=5,
|
| 87 |
title="Image Upscaling 🦆",
|
| 88 |
allow_flagging="never",
|
| 89 |
css=css,
|
| 90 |
+
).launch(debug=True)
|
|
|
minecraft_examples/minecraft-1.jpg
ADDED
|
minecraft_examples/minecraft-2.jpg
ADDED
|
minecraft_examples/minecraft-3.jpg
ADDED
|
minecraft_examples/minecraft-4.jpg
ADDED
|
minecraft_examples/minecraft-5.jpg
ADDED
|
models/minecraft_modelx4.ort
ADDED
|
Binary file (261 kB). View file
|
|
|
models/modelx2.ort
ADDED
|
Binary file (147 kB). View file
|
|
|
models/{model.ort → modelx4.ort}
RENAMED
|
File without changes
|