Spaces:
Runtime error
Runtime error
Png optimized?
Browse files- app.py +2 -2
- inference.py +2 -4
app.py
CHANGED
@@ -20,7 +20,7 @@ def inference(img, size, type):
|
|
20 |
INPUT_DIR = "/tmp/input_image" + str(_id) + "/"
|
21 |
OUTPUT_DIR = "/tmp/output_image" + str(_id) + "/"
|
22 |
img_in_path = os.path.join(INPUT_DIR, "1.jpg")
|
23 |
-
img_out_path = os.path.join(OUTPUT_DIR, "1_out.
|
24 |
run_cmd(f"rm -rf {INPUT_DIR}")
|
25 |
run_cmd(f"rm -rf {OUTPUT_DIR}")
|
26 |
run_cmd(f"mkdir {INPUT_DIR}")
|
@@ -47,7 +47,7 @@ def inference(img, size, type):
|
|
47 |
return [img_out]
|
48 |
|
49 |
input_image = gr.Image(type="pil", label="Input")
|
50 |
-
upscale_type = gr.Radio(["Manga
|
51 |
upscale_size = gr.Radio(["x4", "x2"], label="Upscale by:", value="x4")
|
52 |
output_image = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery").style(grid=[2], height="auto")
|
53 |
|
|
|
20 |
INPUT_DIR = "/tmp/input_image" + str(_id) + "/"
|
21 |
OUTPUT_DIR = "/tmp/output_image" + str(_id) + "/"
|
22 |
img_in_path = os.path.join(INPUT_DIR, "1.jpg")
|
23 |
+
img_out_path = os.path.join(OUTPUT_DIR, "1_out.png")
|
24 |
run_cmd(f"rm -rf {INPUT_DIR}")
|
25 |
run_cmd(f"rm -rf {OUTPUT_DIR}")
|
26 |
run_cmd(f"mkdir {INPUT_DIR}")
|
|
|
47 |
return [img_out]
|
48 |
|
49 |
input_image = gr.Image(type="pil", label="Input")
|
50 |
+
upscale_type = gr.Radio(["Manga", "Anime", "General"], label="Select the type of picture you want to upscale:", value="Manga v2")
|
51 |
upscale_size = gr.Radio(["x4", "x2"], label="Upscale by:", value="x4")
|
52 |
output_image = gr.Gallery(label="Generated images", show_label=False, elem_id="gallery").style(grid=[2], height="auto")
|
53 |
|
inference.py
CHANGED
@@ -13,9 +13,7 @@ def is_cuda():
|
|
13 |
|
14 |
model_type = sys.argv[3]
|
15 |
|
16 |
-
if model_type == "
|
17 |
-
model_path = "4x_eula_digimanga_bw_v1_860k.pth"
|
18 |
-
elif model_type == "Anime":
|
19 |
model_path = "4x-AnimeSharp.pth"
|
20 |
else:
|
21 |
model_path = "4x-UniScaleV2_Sharp.pth"
|
@@ -55,4 +53,4 @@ with torch.no_grad():
|
|
55 |
output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0))
|
56 |
output = (output * 255.0).round()
|
57 |
print('Finished upscaling, saving image.')
|
58 |
-
cv2.imwrite(output_dir, output, [int(cv2.
|
|
|
13 |
|
14 |
model_type = sys.argv[3]
|
15 |
|
16 |
+
if model_type == "Anime":
|
|
|
|
|
17 |
model_path = "4x-AnimeSharp.pth"
|
18 |
else:
|
19 |
model_path = "4x-UniScaleV2_Sharp.pth"
|
|
|
53 |
output = np.transpose(output[[2, 1, 0], :, :], (1, 2, 0))
|
54 |
output = (output * 255.0).round()
|
55 |
print('Finished upscaling, saving image.')
|
56 |
+
cv2.imwrite(output_dir, output, [int(cv2.IMWRITE_PNG_COMPRESSION), 5])
|