Spaces:
Runtime error
Runtime error
Update app.py
Browse files1223454678678910119101112131415161718192021222324251526271728292030import gradio as grfrom huggingface_hub import InferenceClientimport tensorflow as tfimport numpy as npfrom PIL import Image
client = InferenceClient("BillyAggarwal/NeuralStyleTrasnferModel.keras")# Load your Keras modelmodel = tf.keras.models.load_model("NeuralStyleTransferModel.keras")
def style_transfer(content_image, style_image): # send images to Hugging Face model result = client.post( json={"inputs": {"content": content_image, "style": style_image}} ) return resultdef 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 model output = model.predict([content_arr, style_arr])
# postprocess output_img = (output[0] * 255).astype("uint8") return Image.fromarray(output_img)
demo = gr.Interface( fn=style_transfer, inputs=[gr.Image(), gr.Image()], inputs=[gr.Image(type="numpy"), gr.Image(type="numpy")], outputs=gr.Image(), title="Neural Style Transfer")
demo.launch()demo.launch()app.py+21-11