Spaces:
Build error
Build error
| # app.py | |
| import gradio as gr | |
| from stylization import Stylizer | |
| import cv2 | |
| import numpy as np | |
| stylizer = Stylizer() | |
| def stylize_interface(image): | |
| # Convert from PIL to OpenCV format | |
| image = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) | |
| result = stylizer.apply_style_threaded(image) | |
| # Convert back to PIL format | |
| result_rgb = cv2.cvtColor(result, cv2.COLOR_BGR2RGB) | |
| return result_rgb | |
| iface = gr.Interface( | |
| fn=stylize_interface, | |
| inputs=gr.Image(type="pil"), | |
| outputs=gr.Image(type="pil"), | |
| title="Threaded Image Stylizer", | |
| description="Applies stylization filter using OpenCV with threading." | |
| ) | |
| if __name__ == "__main__": | |
| iface.launch() |