Spaces:
Runtime error
Runtime error
Update app.py
Browse files8 unmodified lines91011121314151617181920212284 unmodified lines1071081091101111121138 unmodified linesprint(f"Prediction environment scikit-learn version: {sklearn.__version__}")def decode_file(file_path):with open(file_path, 'rb') as file:obj = pickle.load(file)return obj# Load the model once when starting the apptry:model = decode_file('model.pkl')print("Model loaded successfully")except Exception as e:print(f"Error loading model: {e}")model = None84 unmodified linesprediction = model.predict_proba(processed_input)[0][1]return f"The probability of stroke is {prediction:.2%}"except Exception as e:return f"Error making prediction: {str(e)}"# Create the Gradio interfaceiface = gr.Interface(8 unmodified lines9101112131415161718192021222324252627282930313284 unmodified lines1171181191201211221238 unmodified linesprint(f"Prediction environment scikit-learn version: {sklearn.__version__}")def decode_file(file_path):try:with open(file_path, 'rb') as file:obj = pickle.load(file)return objexcept FileNotFoundError:print(f"Error: File not found at {file_path}")return Noneexcept Exception as e:print(f"Error loading pickle file: {e}")return None# Load the model once when starting the apptry:model = decode_file('./model.pkl') # Updated hereif model is not None:print("Model loaded successfully")else:print("Model loading failed, None value")except Exception as e:print(f"Error loading model: {e}")model = None84 unmodified linesprediction = model.predict_proba(processed_input)[0][1]return f"The probability of stroke is {prediction:.2%}"except Exception as e:return f"Error making prediction: {str(e)}, model is not valid" # updated here# Create the Gradio interfaceiface = gr.Interface(
app.py+16-6