salma-remyx commited on
Commit
88fac11
1 Parent(s): 6d594da

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -0
README.md CHANGED
@@ -17,5 +17,41 @@ tags:
17
  This model fine-tunes Florence-2-base-ft in the POSE task for body keypoint estimation using the PoseText Dataset.
18
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  - **Developed by:** [remyx.ai]
21
  - **Finetuned from model:** [microsoft/Florence-2-base-ft]
 
17
  This model fine-tunes Florence-2-base-ft in the POSE task for body keypoint estimation using the PoseText Dataset.
18
 
19
 
20
+ # Running PoseFlorence-2
21
+ ```python
22
+ import requests
23
+
24
+ import torch
25
+ from PIL import Image
26
+ from transformers import AutoProcessor, AutoModelForCausalLM
27
+
28
+
29
+ device = "cuda:0" if torch.cuda.is_available() else "cpu"
30
+ torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
31
+
32
+ model = AutoModelForCausalLM.from_pretrained("remyxai/PoseeFlorence-2", trust_remote_code=True).to(device)
33
+ processor = AutoProcessor.from_pretrained("remyxai/PoseFlorence-2", trust_remote_code=True)
34
+
35
+ prompt = "<POSE>"
36
+
37
+ url = "https://remyx.ai/assets/spatialvlm/warehouse_rgb.jpg?download=true"
38
+ image = Image.open(requests.get(url, stream=True).raw)
39
+
40
+ inputs = processor(text=prompt, images=image, return_tensors="pt").to(device, torch_dtype)
41
+
42
+ generated_ids = model.generate(
43
+ input_ids=inputs["input_ids"],
44
+ pixel_values=inputs["pixel_values"],
45
+ max_new_tokens=1024,
46
+ num_beams=3,
47
+ do_sample=False
48
+ )
49
+ generated_text = processor.batch_decode(generated_ids, skip_special_tokens=False)[0]
50
+
51
+ parsed_answer = processor.post_process_generation(generated_text, task="<SpatialVQA>", image_size=(image.width, image.height))
52
+
53
+ print(parsed_answer)
54
+ ```
55
+
56
  - **Developed by:** [remyx.ai]
57
  - **Finetuned from model:** [microsoft/Florence-2-base-ft]