Jiayi-Pan commited on
Commit
e834660
1 Parent(s): c926e59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -9,11 +9,9 @@ import gradio as gr
9
  import argparse
10
  import tempfile
11
 
12
- import os
13
  from PIL import Image
14
- import json
15
- from tqdm import tqdm
16
  import easyocr
 
17
 
18
  assert (
19
  __version__ == "4.32.0"
@@ -31,10 +29,14 @@ def get_easy_text(img_file):
31
  return out
32
 
33
  model_name = "DigitalAgent/Captioner"
 
 
 
 
34
  model = (
35
  AutoModelForCausalLM.from_pretrained(
36
- model_name, device_map="cuda", trust_remote_code=True
37
- )
38
  .eval()
39
  .half()
40
  )
 
9
  import argparse
10
  import tempfile
11
 
 
12
  from PIL import Image
 
 
13
  import easyocr
14
+ import torch
15
 
16
  assert (
17
  __version__ == "4.32.0"
 
29
  return out
30
 
31
  model_name = "DigitalAgent/Captioner"
32
+ if torch.cuda.is_available():
33
+ device = torch.device("cuda")
34
+ else:
35
+ device = torch.device("cpu")
36
  model = (
37
  AutoModelForCausalLM.from_pretrained(
38
+ model_name, trust_remote_code=True
39
+ ).to(device)
40
  .eval()
41
  .half()
42
  )