Spaces:
Runtime error
Runtime error
updating
Browse files- nougat_api_app.py +10 -10
nougat_api_app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
-
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
|
4 |
-
os.environ["CUDA_VISIBLE_DEVICES"] = "3" # just use one GPU on big machine
|
5 |
import torch
|
6 |
print ('Available devices ', torch.cuda.device_count())
|
7 |
print ('Current cuda device ', torch.cuda.current_device())
|
@@ -539,6 +539,13 @@ def read_users(skip: int = 0, limit: int = 100, db: Session = Depends(get_db)):
|
|
539 |
users = crud.get_users(db, skip=skip, limit=limit)
|
540 |
return users
|
541 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
def sauvolaBinarize(img:Image = None, dest:str = None):
|
543 |
if dest!= None:
|
544 |
cv2_image = cv2.imread(dest)
|
@@ -561,14 +568,7 @@ def sauvolaBinarize(img:Image = None, dest:str = None):
|
|
561 |
#dest_filename, dest_ext = os.path.splitext(dest)
|
562 |
img.save( './uploads/testBinarization' + ".png", "PNG")
|
563 |
return img
|
564 |
-
|
565 |
-
def stringToBool(string: str) -> bool:
|
566 |
-
match(string.lower()):
|
567 |
-
case 'true':
|
568 |
-
return True
|
569 |
-
case 'false':
|
570 |
-
return False
|
571 |
-
|
572 |
@app.post("/predict")
|
573 |
async def predict(
|
574 |
request: Request,
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
#os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
|
4 |
+
#os.environ["CUDA_VISIBLE_DEVICES"] = "3" # just use one GPU on big machine
|
5 |
import torch
|
6 |
print ('Available devices ', torch.cuda.device_count())
|
7 |
print ('Current cuda device ', torch.cuda.current_device())
|
|
|
539 |
users = crud.get_users(db, skip=skip, limit=limit)
|
540 |
return users
|
541 |
|
542 |
+
def stringToBool(string:str) -> bool:
|
543 |
+
if (string.lower()=="true"):
|
544 |
+
return True
|
545 |
+
elif(string.lower()=="false"):
|
546 |
+
return False
|
547 |
+
else: return False
|
548 |
+
|
549 |
def sauvolaBinarize(img:Image = None, dest:str = None):
|
550 |
if dest!= None:
|
551 |
cv2_image = cv2.imread(dest)
|
|
|
568 |
#dest_filename, dest_ext = os.path.splitext(dest)
|
569 |
img.save( './uploads/testBinarization' + ".png", "PNG")
|
570 |
return img
|
571 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
@app.post("/predict")
|
573 |
async def predict(
|
574 |
request: Request,
|