Spaces:
Running
on
Zero
Running
on
Zero
srijaydeshpande
commited on
Update
Browse files
app.py
CHANGED
@@ -4,18 +4,20 @@ from tqdm import tqdm
|
|
4 |
import re
|
5 |
import gradio as gr
|
6 |
import os
|
7 |
-
from llama_cpp import Llama
|
8 |
# from gpt4all import GPT4All
|
9 |
-
import transformers
|
10 |
# from transformers import GemmaTokenizer, AutoModelForCausalLM
|
11 |
# from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
12 |
import accelerate
|
13 |
-
import
|
|
|
14 |
import subprocess
|
15 |
|
16 |
subprocess.run('pip install llama-cpp-python==0.2.75 --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124', shell=True)
|
17 |
subprocess.run('pip install llama-cpp-agent==0.2.10', shell=True)
|
18 |
|
|
|
|
|
19 |
# HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
20 |
|
21 |
def process_document(pdf_path, page_ids=None):
|
@@ -124,6 +126,7 @@ def mkdir(dir):
|
|
124 |
if not os.path.exists(dir):
|
125 |
os.makedirs(dir)
|
126 |
|
|
|
127 |
def pdf_to_text(files, output_folder, prompt, maxtokens=600, temperature=1.2, top_probability=0.95):
|
128 |
output_folder = output_folder.replace('\\','/')
|
129 |
for file in files:
|
|
|
4 |
import re
|
5 |
import gradio as gr
|
6 |
import os
|
|
|
7 |
# from gpt4all import GPT4All
|
8 |
+
# import transformers
|
9 |
# from transformers import GemmaTokenizer, AutoModelForCausalLM
|
10 |
# from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
11 |
import accelerate
|
12 |
+
import spaces
|
13 |
+
# import torch
|
14 |
import subprocess
|
15 |
|
16 |
subprocess.run('pip install llama-cpp-python==0.2.75 --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cu124', shell=True)
|
17 |
subprocess.run('pip install llama-cpp-agent==0.2.10', shell=True)
|
18 |
|
19 |
+
from llama_cpp import Llama
|
20 |
+
|
21 |
# HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
22 |
|
23 |
def process_document(pdf_path, page_ids=None):
|
|
|
126 |
if not os.path.exists(dir):
|
127 |
os.makedirs(dir)
|
128 |
|
129 |
+
@spaces.GPU(duration=120)
|
130 |
def pdf_to_text(files, output_folder, prompt, maxtokens=600, temperature=1.2, top_probability=0.95):
|
131 |
output_folder = output_folder.replace('\\','/')
|
132 |
for file in files:
|