Spaces:
Running
on
Zero
Running
on
Zero
MohamedRashad
commited on
Commit
·
ea38d8e
1
Parent(s):
71311e8
Update device selection for model
Browse files
app.py
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
from transformers import NougatProcessor, VisionEncoderDecoderModel
|
2 |
import gradio as gr
|
|
|
3 |
from pdf2image import convert_from_path
|
4 |
|
5 |
# Load the model and processor
|
6 |
processor = NougatProcessor.from_pretrained("MohamedRashad/arabic-small-nougat")
|
7 |
model = VisionEncoderDecoderModel.from_pretrained("MohamedRashad/arabic-small-nougat")
|
8 |
-
device = "cpu"
|
9 |
|
10 |
context_length = 2048
|
11 |
|
|
|
1 |
from transformers import NougatProcessor, VisionEncoderDecoderModel
|
2 |
import gradio as gr
|
3 |
+
import torch
|
4 |
from pdf2image import convert_from_path
|
5 |
|
6 |
# Load the model and processor
|
7 |
processor = NougatProcessor.from_pretrained("MohamedRashad/arabic-small-nougat")
|
8 |
model = VisionEncoderDecoderModel.from_pretrained("MohamedRashad/arabic-small-nougat")
|
9 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
10 |
|
11 |
context_length = 2048
|
12 |
|