jonathanjordan21 commited on
Commit
f52f608
·
1 Parent(s): aa6eacc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -6,17 +6,20 @@ import torch
6
 
7
  from transformers import DonutProcessor, VisionEncoderDecoderModel
8
 
9
- # Check GPU
10
- device = "cuda" if torch.cuda.is_available() else "cpu"
 
 
11
 
12
- # Load processor
13
- processor = DonutProcessor.from_pretrained("jonathanjordan21/donut_fine_tuning_food_composition_id")
14
 
15
- # Load model
16
- model = VisionEncoderDecoderModel.from_pretrained("jonathanjordan21/donut_fine_tuning_food_composition_id")
 
17
 
18
- # Define Json Parser
19
- def get_komposisi(image_path, image=None):
20
  image = Image.open(image_path).convert('RGB') if image== None else image.convert('RGB')
21
 
22
  task_prompt = "<s_kmpsi>"
@@ -42,8 +45,6 @@ def get_komposisi(image_path, image=None):
42
 
43
  return processor.token2json(sequence3)
44
 
45
-
46
- def predict(inp):
47
  #Generate Output
48
  out = get_komposisi("", inp)
49
  return out
 
6
 
7
  from transformers import DonutProcessor, VisionEncoderDecoderModel
8
 
9
+ def predict(inp):
10
+
11
+ # Check GPU
12
+ device = "cuda" if torch.cuda.is_available() else "cpu"
13
 
14
+ # Load processor
15
+ processor = DonutProcessor.from_pretrained("jonathanjordan21/donut_fine_tuning_food_composition_id")
16
 
17
+ # Load model
18
+ model = VisionEncoderDecoderModel.from_pretrained("jonathanjordan21/donut_fine_tuning_food_composition_id")
19
+
20
 
21
+ # Define Json Parser
22
+ def get_komposisi(image_path, image=None):
23
  image = Image.open(image_path).convert('RGB') if image== None else image.convert('RGB')
24
 
25
  task_prompt = "<s_kmpsi>"
 
45
 
46
  return processor.token2json(sequence3)
47
 
 
 
48
  #Generate Output
49
  out = get_komposisi("", inp)
50
  return out