Inni-23 commited on
Commit
ed8c152
·
1 Parent(s): 8d0fde0
Files changed (3) hide show
  1. app.py +42 -0
  2. omni_rnn_0.h5 +3 -0
  3. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import numpy as np
3
+ from tensorflow import keras
4
+
5
+ # Load the pre-trained model
6
+ model = keras.models.load_model('omni_rnn_0.h5')
7
+
8
+ def predict(year, proton_density, temperature):
9
+ try:
10
+ # Ensure the input data has the correct types and ranges
11
+ year = int(year)
12
+ proton_density = float(proton_density)
13
+ temperature = float(temperature)
14
+
15
+ # Ensure the input data is within valid ranges
16
+ if year < 0 or proton_density < 0 or temperature < 0:
17
+ return {"error": "Input values should be non-negative"}
18
+
19
+ # Convert input data to a NumPy array
20
+ input_data = np.array([year, proton_density, temperature]).reshape(1, -1)
21
+
22
+ # Make predictions using the loaded model
23
+ predictions = model.predict(input_data)
24
+
25
+ # Format the predictions as a dictionary
26
+ result = {
27
+ "predicted_speed": float(predictions[0, 0]),
28
+ "predicted_field_magnitude": float(predictions[0, 1])
29
+ }
30
+
31
+ return result
32
+
33
+ except Exception as e:
34
+ return {"error": str(e)}
35
+
36
+ iface = gr.Interface(
37
+ fn=predict,
38
+ inputs=["text", "text", "text"], # Year, Proton Density, Temperature
39
+ outputs="json"
40
+ )
41
+
42
+ iface.launch()
omni_rnn_0.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48024055b87eaac2c44ed186d9b21cf8d7acf6bce6b7fb81ea9e4f5f7b02570d
3
+ size 154352
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ flask
2
+ flask-cors
3
+ tensorflow