Spaces:
Runtime error
Runtime error
Update app.py
Browse files1234567891011121314151617181920import gradio as grfrom huggingface_hub import InferenceClientclient = InferenceClient("BillyAggarwal/NeuralStyleTrasnferModel.keras")def style_transfer(content_image, style_image):# send images to Hugging Face modelresult = client.post(json={"inputs": {"content": content_image, "style": style_image}})return resultdemo = gr.Interface(fn=style_transfer,inputs=[gr.Image(), gr.Image()],outputs=gr.Image(),title="Neural Style Transfer")demo.launch()123456789101112131415161718192021222324252627282930import gradio as grimport tensorflow as tfimport numpy as npfrom PIL import Image# Load your Keras modelmodel = tf.keras.models.load_model("NeuralStyleTransferModel.keras")def style_transfer(content, style):content = Image.fromarray(content).resize((256, 256))style = Image.fromarray(style).resize((256, 256))# preprocess (example: normalize, expand dims, etc.)content_arr = np.expand_dims(np.array(content) / 255.0, axis=0)style_arr = np.expand_dims(np.array(style) / 255.0, axis=0)# run through your modeloutput = model.predict([content_arr, style_arr])# postprocessoutput_img = (output[0] * 255).astype("uint8")return Image.fromarray(output_img)demo = gr.Interface(fn=style_transfer,inputs=[gr.Image(type="numpy"), gr.Image(type="numpy")],outputs=gr.Image(),)demo.launch()
app.py+21-11