nielsr HF Staff commited on
Commit
404c3cb
·
verified ·
1 Parent(s): d7f2395

Improve model card

Browse files

The code snippet was wrong, this PR fixes it.

Files changed (1) hide show
  1. README.md +2 -68
README.md CHANGED
@@ -3,7 +3,6 @@ datasets:
3
  - michaelyuanqwq/roboseg
4
  license: mit
5
  pipeline_tag: image-segmentation
6
- library_name: transformers
7
  tags:
8
  - segmentation
9
  - robotics
@@ -23,75 +22,10 @@ Visual augmentation has become a crucial technique for enhancing the visual robu
23
 
24
  ## Usage
25
 
26
- This model is a Robo-SAM checkpoint and can be loaded using the Hugging Face `transformers` library with `trust_remote_code=True`. It can be used for semantic robot segmentation.
27
 
28
- ```python
29
- from transformers import AutoProcessor, AutoModel
30
- from PIL import Image
31
- import torch
32
- import numpy as np
33
 
34
- # Load model and processor
35
- # Make sure you have installed `transformers` and `torch`
36
- # If you encounter errors, try `pip install torch` and `pip install transformers`
37
- model = AutoModel.from_pretrained("michaelyuanqwq/roboengine-sam", trust_remote_code=True)
38
- processor = AutoProcessor.from_pretrained("michaelyuanqwq/roboengine-sam", trust_remote_code=True)
39
-
40
- # Example image input: replace 'your_robot_image.png' with the actual path to your image.
41
- # You can find example images in the original GitHub repository:
42
- # https://github.com/michaelyuancb/roboengine/tree/main/assets
43
- try:
44
- # Create a dummy image if file not found for demonstration
45
- try:
46
- raw_image = Image.open("your_robot_image.png").convert("RGB")
47
- except FileNotFoundError:
48
- print("Sample image 'your_robot_image.png' not found. Creating a dummy white image for demonstration.")
49
- raw_image = Image.new('RGB', (512, 512), color = 'white')
50
-
51
- # Prepare inputs for semantic robot segmentation
52
- # The model expects input points or bounding boxes. A central point is often used
53
- # as a default to prompt for the main object (robot) in the image.
54
- input_points = [[[raw_image.height / 2, raw_image.width / 2]]]
55
-
56
- inputs = processor(raw_image, input_points=input_points, return_tensors="pt")
57
- # Move inputs to the appropriate device (e.g., GPU if available)
58
- if torch.cuda.is_available():
59
- for k,v in inputs.items():
60
- if isinstance(v, torch.Tensor):
61
- inputs[k] = v.to(model.device)
62
-
63
- # Perform inference
64
- with torch.no_grad():
65
- outputs = model(**inputs)
66
-
67
- # Post-process masks
68
- # The output `outputs.pred_masks` contains the predicted masks.
69
- # `post_process_masks` converts them to original image dimensions.
70
- masks = processor.post_process_masks(
71
- outputs.pred_masks.cpu(),
72
- inputs["original_sizes"].cpu(),
73
- inputs["reshaped_input_sizes"].cpu()
74
- )[0] # Take the masks for the first image in the batch
75
-
76
- # `masks` is a list of dictionaries, each describing a segmented object.
77
- # The 'segmentation' key contains a boolean NumPy array.
78
- if masks:
79
- # Assuming the first mask is the primary robot segmentation
80
- robot_mask_array = masks[0]['segmentation'].numpy()
81
- # Save the mask as an image (e.g., black where not robot, white where robot)
82
- Image.fromarray(robot_mask_array.astype(np.uint8) * 255).save("robot_segmented_mask.png")
83
- print("Robot segmentation mask saved as robot_segmented_mask.png")
84
- else:
85
- print("No masks were generated for the input image.")
86
-
87
- except Exception as e:
88
- print(f"An error occurred during usage example: {e}")
89
- print("Please ensure all dependencies are installed and provide a valid image path.")
90
-
91
- ```
92
- For a more comprehensive understanding and usage of RoboEngine as a full toolkit for robot data augmentation, please refer to the [official GitHub repository](https://github.com/michaelyuancb/roboengine).
93
-
94
- ## BibTex
95
  ```bibtex
96
  @article{yuan2025roboengine,
97
  title={RoboEngine: Plug-and-Play Robot Data Augmentation with Semantic Robot Segmentation and Background Generation},
 
3
  - michaelyuanqwq/roboseg
4
  license: mit
5
  pipeline_tag: image-segmentation
 
6
  tags:
7
  - segmentation
8
  - robotics
 
22
 
23
  ## Usage
24
 
25
+ Refer to the [official GitHub repository](https://github.com/michaelyuancb/roboengine).
26
 
27
+ ## Citation
 
 
 
 
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  ```bibtex
30
  @article{yuan2025roboengine,
31
  title={RoboEngine: Plug-and-Play Robot Data Augmentation with Semantic Robot Segmentation and Background Generation},