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()