Commit 15ef1c04 authored by janithGamage's avatar janithGamage

fix: update

Desc : update project
parent 5378cc0a
......@@ -2,6 +2,7 @@
"cSpell.words": [
"Countup",
"Janith",
"mocq",
"SLIIT"
]
}
\ No newline at end of file
......@@ -10,6 +10,26 @@
"pip install python-multipart"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "10a7c02f",
"metadata": {},
"outputs": [],
"source": [
"pip install fastapi"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f66f541c",
"metadata": {},
"outputs": [],
"source": [
"pip install uvicorn"
]
},
{
"cell_type": "code",
"execution_count": null,
......
......@@ -2,9 +2,78 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 27,
"id": "3d735e52",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: fastapi in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (0.95.2)\n",
"Requirement already satisfied: starlette<0.28.0,>=0.27.0 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from fastapi) (0.27.0)\n",
"Requirement already satisfied: pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from fastapi) (1.10.8)\n",
"Requirement already satisfied: typing-extensions>=4.2.0 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2->fastapi) (4.3.0)\n",
"Requirement already satisfied: anyio<5,>=3.4.0 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from starlette<0.28.0,>=0.27.0->fastapi) (3.5.0)\n",
"Requirement already satisfied: sniffio>=1.1 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from anyio<5,>=3.4.0->starlette<0.28.0,>=0.27.0->fastapi) (1.2.0)\n",
"Requirement already satisfied: idna>=2.8 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from anyio<5,>=3.4.0->starlette<0.28.0,>=0.27.0->fastapi) (3.4)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"pip install fastapi"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "8f281d93",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: uvicorn in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (0.22.0)\n",
"Requirement already satisfied: click>=7.0 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from uvicorn) (8.1.3)\n",
"Requirement already satisfied: h11>=0.8 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from uvicorn) (0.14.0)\n",
"Requirement already satisfied: typing-extensions in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from uvicorn) (4.3.0)\n",
"Requirement already satisfied: importlib-metadata in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from click>=7.0->uvicorn) (4.11.3)\n",
"Requirement already satisfied: colorama in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from click>=7.0->uvicorn) (0.4.6)\n",
"Requirement already satisfied: zipp>=0.5 in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (from importlib-metadata->click>=7.0->uvicorn) (3.11.0)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"pip install uvicorn"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "97a4a52c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: python-multipart in c:\\users\\janithgamage\\.conda\\envs\\test\\lib\\site-packages (0.0.6)\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"pip install python-multipart"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "540c9e2f",
"metadata": {},
"outputs": [],
"source": [
"import nest_asyncio\n",
......@@ -17,7 +86,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 31,
"id": "db756418",
"metadata": {},
"outputs": [],
......@@ -36,7 +105,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 32,
"id": "fc83d1b8",
"metadata": {},
"outputs": [],
......@@ -46,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 33,
"id": "63dbfc01",
"metadata": {},
"outputs": [],
......@@ -61,7 +130,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 34,
"id": "f7e5cdba",
"metadata": {},
"outputs": [],
......@@ -103,7 +172,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 35,
"id": "d86a9515",
"metadata": {},
"outputs": [
......@@ -118,7 +187,7 @@
")"
]
},
"execution_count": 6,
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
......@@ -131,34 +200,37 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 36,
"id": "4b527135",
"metadata": {},
"outputs": [],
"source": [
"@app.post(\"/predict-similarity\")\n",
"async def predict_similarity(image: UploadFile):\n",
" image_bytes = await image.read()\n",
" img = Image.open(BytesIO(image_bytes))\n",
" img = transform(img).unsqueeze(0)\n",
" output = model(img)\n",
" print(output)\n",
" # Get the maximum predicted probability as the similarity score\n",
" similarity_score = torch.max(output).item() * 100\n",
" similarity_score1 = torch.min(output).item() * 100\n",
" \n",
" return {\"similarity_score\": similarity_score}\n",
"\n",
"# @app.post(\"/predict-similarity\")\n",
"# async def predict_similarity(image: UploadFile):\n",
"# async def predict_similarity(sign: str, image: UploadFile):\n",
"# image_bytes = await image.read()\n",
"# img = Image.open(BytesIO(image_bytes))\n",
"# img = transform(img).unsqueeze(0)\n",
"# output = model(img)\n",
"# similarity_score = torch.max(output).item() * 100 # Get the maximum predicted probability as the similarity score\n",
"# return {\"similarity_score\": similarity_score}\n",
"\n",
"\n",
"@app.post(\"/predict-similarity\")\n",
"async def predict_similarity(sign: str, image: UploadFile):\n",
" image_bytes = await image.read()\n",
" img = Image.open(BytesIO(image_bytes))\n",
" img = transform(img).unsqueeze(0)\n",
" output = model(img)\n",
" similarity_score = torch.max(output).item() * 100 # Get the maximum predicted probability as the similarity score\n",
" return {\"sign\": sign, \"similarity_score\": similarity_score}"
"# return {\"sign\": sign, \"similarity_score\": similarity_score}\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 37,
"id": "df08611e",
"metadata": {},
"outputs": [],
......@@ -171,7 +243,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 38,
"id": "84b9601b",
"metadata": {},
"outputs": [
......@@ -179,7 +251,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"INFO: Started server process [36440]\n",
"INFO: Started server process [29948]\n",
"INFO: Waiting for application startup.\n",
"INFO: Application startup complete.\n",
"INFO: Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)\n"
......@@ -189,17 +261,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"INFO: 127.0.0.1:63408 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63440 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63461 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63484 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63502 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63517 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63523 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63536 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63536 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63536 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n",
"INFO: 127.0.0.1:63546 - \"POST /predict-similarity HTTP/1.1\" 422 Unprocessable Entity\n"
"tensor([[2.0707e-08, 1.3095e-06, 4.2269e-09, 3.1405e-08, 7.0333e-13, 1.3519e-07,\n",
" 2.7351e-16, 9.9999e-01, 7.2929e-18, 5.1420e-11, 3.3166e-06, 1.7149e-09,\n",
" 4.6723e-10, 5.4727e-07, 3.0778e-10, 3.3862e-13]],\n",
" grad_fn=<SoftmaxBackward0>)\n",
"INFO: 127.0.0.1:52609 - \"POST /predict-similarity HTTP/1.1\" 200 OK\n"
]
}
],
......@@ -243,7 +309,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.7.16"
}
},
"nbformat": 4,
......
......@@ -11,6 +11,7 @@ logger = setup_logger()
app.include_router(users_controller.router)
app.include_router(translate_controler.router)
# app.include_router(users_controller.router)
# Add cores middleware
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment