nkasmanoff commited on
Commit
529bd38
1 Parent(s): 7049830

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -13,8 +13,13 @@ def predict(image,max_length=64,device='cpu'):
13
  pixel_values = processor(images=image, return_tensors="pt").to(device).pixel_values
14
  generated_ids = model.generate(pixel_values=pixel_values, max_length=max_length)
15
  generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
16
-
17
- return generated_caption
 
 
 
 
 
18
 
19
 
20
  input = gr.inputs.Image(label="Please upload a remote sensing image", type = 'pil', optional=True)
 
13
  pixel_values = processor(images=image, return_tensors="pt").to(device).pixel_values
14
  generated_ids = model.generate(pixel_values=pixel_values, max_length=max_length)
15
  generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
16
+ relation = get_relations(generated_caption)
17
+
18
+ entity_pair = get_entities(generated_caption)
19
+
20
+ knowlege_triplet = f"{entity_pair[0]}-{relation}->{entity_pair[1]}"
21
+
22
+ return knowlege_triplet
23
 
24
 
25
  input = gr.inputs.Image(label="Please upload a remote sensing image", type = 'pil', optional=True)