|
|
| import gradio as gr |
| import numpy as np |
| from tensorflow.keras.models import load_model |
|
|
| |
| model2 = load_model('shoplifting_model.h5') |
|
|
| def predict_from_npy(npy_file): |
| try: |
| |
| data = np.load(npy_file.name, allow_pickle=True) |
|
|
| |
| reshaped_data = data.reshape(30, 51) |
|
|
| |
| prediction = model2.predict(np.expand_dims(reshaped_data, axis=0)) |
| threshold = 0.5 |
| predicted_class = 'Shoplifting' if prediction[0][0] > threshold else 'Normal' |
|
|
| return predicted_class |
| except Exception as e: |
| return f"Error: {e}" |
|
|
| |
| iface = gr.Interface( |
| fn=predict_from_npy, |
| inputs=gr.File(label="Upload .npy File"), |
| outputs="text", |
| title="Shoplifting Prediction from .npy", |
| description="Upload an .npy file containing keypoint data to get a shoplifting prediction." |
| ) |
|
|
| |
| iface.launch(debug=True) |