Hammad712 commited on
Commit
105bb91
·
verified ·
1 Parent(s): b9c3f54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -2,8 +2,9 @@ import streamlit as st
2
  import tensorflow as tf
3
  from tensorflow_addons.layers import InstanceNormalization
4
  import numpy as np
5
- from PIL import Image
6
  from huggingface_hub import hf_hub_download
 
7
  import requests
8
  from io import BytesIO
9
  import os
@@ -63,15 +64,11 @@ repo_name = "CycleGAN-Model"
63
  repo_id = f"{username}/{repo_name}"
64
  model_filename = "CycleGAN.h5"
65
 
66
- try:
67
- # Download the model file from the repository
68
- model_path = hf_hub_download(repo_id=repo_id, filename=model_filename)
69
- # Load the model
70
- model = tf.keras.models.load_model(model_path, custom_objects={"InstanceNormalization": InstanceNormalization})
71
- st.success("Model loaded successfully!")
72
- except Exception as e:
73
- st.error(f"An error occurred while loading the model: {e}")
74
- st.stop()
75
 
76
  def load_and_preprocess_image(image_path_or_url):
77
  if isinstance(image_path_or_url, str) and image_path_or_url.startswith(('http://', 'https://')):
 
2
  import tensorflow as tf
3
  from tensorflow_addons.layers import InstanceNormalization
4
  import numpy as np
5
+ import matplotlib.pyplot as plt
6
  from huggingface_hub import hf_hub_download
7
+ from PIL import Image
8
  import requests
9
  from io import BytesIO
10
  import os
 
64
  repo_id = f"{username}/{repo_name}"
65
  model_filename = "CycleGAN.h5"
66
 
67
+ # Download the model file from the repository
68
+ model_path = hf_hub_download(repo_id=repo_id, filename=model_filename)
69
+
70
+ # Load the model
71
+ model = tf.keras.models.load_model(model_path, custom_objects={"InstanceNormalization": InstanceNormalization})
 
 
 
 
72
 
73
  def load_and_preprocess_image(image_path_or_url):
74
  if isinstance(image_path_or_url, str) and image_path_or_url.startswith(('http://', 'https://')):