coutant commited on
Commit
3d3c04e
1 Parent(s): 3c131eb

fix device cuda if available

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -1,10 +1,10 @@
1
  import PIL.Image
2
  import gradio as gr
3
-
4
  import numpy as np
5
  from craft_text_detector import Craft
6
 
7
- craft = Craft(output_dir='output', crop_type="box", cuda=True, export_extra=True)
8
 
9
  dw=0.3
10
  dh=0.25
@@ -51,7 +51,7 @@ def detect(image: PIL.Image.Image):
51
 
52
  def process(image:PIL.Image.Image):
53
  if image is None:
54
- return None,0
55
  boxes,signed = detect( image)
56
  annotated = PIL.Image.open('output/image_text_detection.png') # image with boxes displayed
57
  return annotated, len(boxes), signed
 
1
  import PIL.Image
2
  import gradio as gr
3
+ import torch
4
  import numpy as np
5
  from craft_text_detector import Craft
6
 
7
+ craft = Craft(output_dir='output', crop_type="box", cuda=torch.cuda.is_available(), export_extra=True)
8
 
9
  dw=0.3
10
  dh=0.25
 
51
 
52
  def process(image:PIL.Image.Image):
53
  if image is None:
54
+ return None,0,False
55
  boxes,signed = detect( image)
56
  annotated = PIL.Image.open('output/image_text_detection.png') # image with boxes displayed
57
  return annotated, len(boxes), signed