Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pomegranate-farming-monitoring-system
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TMP2023-229
pomegranate-farming-monitoring-system
Commits
f3a0ce73
Commit
f3a0ce73
authored
Oct 29, 2023
by
Gimhan A.H.L.D.K
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'IT20094218' into 'master'
It20094218 See merge request
!1
parents
29059848
8e7792f9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
59 additions
and
0 deletions
+59
-0
Pest-Disease-Prediction-Backend/.gitignore
Pest-Disease-Prediction-Backend/.gitignore
+4
-0
Pest-Disease-Prediction-Backend/app.py
Pest-Disease-Prediction-Backend/app.py
+48
-0
Pest-Disease-Prediction-Backend/gunicorn_config.py
Pest-Disease-Prediction-Backend/gunicorn_config.py
+6
-0
Pest-Disease-Prediction-Backend/models/pest_disease.pickle
Pest-Disease-Prediction-Backend/models/pest_disease.pickle
+0
-0
Pest-Disease-Prediction-Backend/requirements.txt
Pest-Disease-Prediction-Backend/requirements.txt
+0
-0
test.txt
test.txt
+1
-0
No files found.
Pest-Disease-Prediction-Backend/.gitignore
0 → 100644
View file @
f3a0ce73
__pycache__/
*.pyc
myenv/
Pest-Disease-Prediction-Backend/app.py
0 → 100644
View file @
f3a0ce73
from
fastapi
import
FastAPI
from
pydantic
import
BaseModel
import
joblib
import
numpy
as
np
import
os
import
pickle
# Load your machine learning model
current_directory
=
os
.
getcwd
()
model_path
=
"./models/pest_disease.pickle"
# Replace with the path to your model
with
open
(
model_path
,
'rb'
)
as
model_file
:
pest_disease
=
pickle
.
load
(
model_file
)
# Create a FastAPI app
app
=
FastAPI
()
# Define input and output data models
class
InputData
(
BaseModel
):
temperature
:
float
humidity
:
float
wind_speed
:
float
disease_num
:
int
rain
:
int
class
OutputData
(
BaseModel
):
status
:
str
# Function to map status_num to descriptive labels
def
get_status_label
(
status_num
):
if
status_num
==
1
:
return
"high"
elif
status_num
==
2
:
return
"medium"
elif
status_num
==
3
:
return
"low"
else
:
return
"unknown"
@
app
.
get
(
"/"
)
def
read_root
():
return
{
"message"
:
"Hello, FastAPI!"
}
# Create a prediction endpoint for pest and disease model
@
app
.
post
(
"/pest-disease"
,
response_model
=
OutputData
)
async
def
predict_pest_disease
(
input_data
:
InputData
):
input_values
=
np
.
array
([
input_data
.
temperature
,
input_data
.
humidity
,
input_data
.
wind_speed
,
input_data
.
disease_num
,
input_data
.
rain
])
.
reshape
(
1
,
-
1
)
prediction
=
pest_disease
.
predict
(
input_values
)
status_label
=
get_status_label
(
int
(
prediction
))
return
{
"status"
:
status_label
}
Pest-Disease-Prediction-Backend/gunicorn_config.py
0 → 100644
View file @
f3a0ce73
workers
=
4
# Adjust this value based on your server's resources
bind
=
"0.0.0.0:8000"
# Bind to all available network interfaces
# Optionally, set a log file
accesslog
=
"/path/to/access.log"
errorlog
=
"/path/to/error.log"
Pest-Disease-Prediction-Backend/models/pest_disease.pickle
0 → 100644
View file @
f3a0ce73
File added
Pest-Disease-Prediction-Backend/requirements.txt
0 → 100644
View file @
f3a0ce73
B
annotated-types==0.5.0
test.txt
0 → 100644
View file @
f3a0ce73
Hello
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment