File size: 950 Bytes
a4d851a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
import os
from model.model import TextureSynthesisCNN
from model.utils import convert_tensor_to_PIL_image


def image_mod(image):
    return image.rotate(45)

def synth_image(image):
    synthesizer = TextureSynthesisCNN(tex_exemplar_image=image)
    output_tensor = synthesizer.synthesize_texture(num_epochs=10)
    output_image = convert_tensor_to_PIL_image(output_tensor)
    return output_image


demo = gr.Interface(
    fn=synth_image,
    inputs=[gr.Image(type="numpy")],
    outputs=[gr.Image(type="pil")],
    flagging_options=["blurry", "incorrect"],
    examples=[
        os.path.join(os.path.dirname(__file__), "images/blotchy_0025.png"),
        os.path.join(os.path.dirname(__file__), "images/blotchy_0027.png"),
        os.path.join(os.path.dirname(__file__), "images/cracked_0080.png"),
        os.path.join(os.path.dirname(__file__), "images/scenery.png"),
    ],
)

if __name__ == "__main__":
    demo.launch()