Spaces:
Sleeping
Sleeping
Commit
·
ee3e2d2
1
Parent(s):
f54310e
test
Browse files
app.py
CHANGED
@@ -2,7 +2,8 @@ from PIL import Image
|
|
2 |
import pytesseract
|
3 |
import os
|
4 |
import pymupdf
|
5 |
-
|
|
|
6 |
import gradio as gr
|
7 |
from prepare import prepare
|
8 |
|
@@ -20,7 +21,7 @@ from langchain_core.messages import AIMessage, HumanMessage
|
|
20 |
from langchain_community.llms import HuggingFaceEndpoint
|
21 |
from dotenv import load_dotenv
|
22 |
|
23 |
-
|
24 |
|
25 |
|
26 |
def read_pdf(file_path):
|
@@ -47,7 +48,9 @@ def read_pdf(file_path):
|
|
47 |
return output
|
48 |
|
49 |
# Function to query Hugging Face endpoint
|
|
|
50 |
def query_huggingface(text):
|
|
|
51 |
load_dotenv()
|
52 |
api_token = os.getenv("API_TOKEN")
|
53 |
repo_id = "google/gemma-2-9b-it"
|
|
|
2 |
import pytesseract
|
3 |
import os
|
4 |
import pymupdf
|
5 |
+
import spaces
|
6 |
+
import torch
|
7 |
import gradio as gr
|
8 |
from prepare import prepare
|
9 |
|
|
|
21 |
from langchain_community.llms import HuggingFaceEndpoint
|
22 |
from dotenv import load_dotenv
|
23 |
|
24 |
+
zero = torch.Tensor([0]).cuda()
|
25 |
|
26 |
|
27 |
def read_pdf(file_path):
|
|
|
48 |
return output
|
49 |
|
50 |
# Function to query Hugging Face endpoint
|
51 |
+
@spaces.GPU
|
52 |
def query_huggingface(text):
|
53 |
+
print(zero.device)
|
54 |
load_dotenv()
|
55 |
api_token = os.getenv("API_TOKEN")
|
56 |
repo_id = "google/gemma-2-9b-it"
|