Spaces:
Runtime error
Runtime error
streetyogi
commited on
Commit
·
420d681
1
Parent(s):
3e26431
Update inference_server.py
Browse files- inference_server.py +13 -0
inference_server.py
CHANGED
@@ -1,8 +1,21 @@
|
|
|
|
1 |
import uvicorn
|
2 |
from fastapi import FastAPI
|
3 |
|
4 |
app = FastAPI()
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
# Here you can do things such as load your models
|
7 |
|
8 |
@app.get("/")
|
|
|
1 |
+
from sklearn.linear_model import SGDClassifier
|
2 |
import uvicorn
|
3 |
from fastapi import FastAPI
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
7 |
+
def predict(input_text: str):
|
8 |
+
data = [[ord(c) for c in input_text]] # Convert the string to a list of ASCII values
|
9 |
+
model = train(data)
|
10 |
+
# Make a prediction
|
11 |
+
prediction = model.predict([[ord(c) for c in 'abc']]) # Convert the input string to a list of ASCII values
|
12 |
+
return {"prediction": prediction}
|
13 |
+
|
14 |
+
def train(X):
|
15 |
+
model = SGDClassifier()
|
16 |
+
model.fit(X, X) # In this case, we are using the input data as the labels
|
17 |
+
return model
|
18 |
+
|
19 |
# Here you can do things such as load your models
|
20 |
|
21 |
@app.get("/")
|