Skip to content

Commit f3b879f

Browse files
committed
update
1 parent 2640af9 commit f3b879f

File tree

7 files changed

+59
-37
lines changed

7 files changed

+59
-37
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
build/
22
chatrex.egg-info/
33
checkpoints/
4-
tmp/
4+
tmp/
5+
.vscode/

LICENSE

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,31 +49,3 @@ Licensee has not been granted any trademark license as part of this License and
4949
8. APPLICABLE LAW; DISPUTE RESOLUTION
5050

5151
This License will be governed and construed under the laws of the People’s Republic of China without regard to conflicts of law provisions. The parties expressly agree that the United Nations Convention on Contracts for the International Sale of Goods will not apply. Any suit or proceeding arising out of or relating to this License will be brought in the courts, as applicable, in Shenzhen, Guangdong, and each party irrevocably submits to the jurisdiction and venue of such courts.
52-
53-
----------------License for Vicuna-7B-V1.5------------------
54-
55-
Llama 2 Version Release Date: July 18, 2023
56-
“Agreement” means the terms and conditions for use, reproduction, distribution and modification of the Llama Materials set forth herein.
57-
“Documentation” means the specifications, manuals and documentation accompanying Llama 2 distributed by Meta at ai.meta.com/resources/models-and-libraries/llama-downloads/.
58-
“Licensee” or “you” means you, or your employer or any other person or entity (if you are entering into this Agreement on such person or entity’s behalf), of the age required under applicable laws, rules or regulations to provide legal consent and that has legal authority to bind your employer or such other person or entity if you are entering in this Agreement on their behalf.
59-
“Llama 2” means the foundational large language models and software and algorithms, including machine-learning model code, trained model weights, inference-enabling code, training-enabling code, fine-tuning enabling code and other elements of the foregoing distributed by Meta at ai.meta.com/resources/models-and-libraries/llama-downloads/.
60-
“Llama Materials” means, collectively, Meta’s proprietary Llama 2 and Documentation (and any portion thereof) made available under this Agreement.
61-
“Meta” or “we” means Meta Platforms Ireland Limited (if you are located in or, if you are an entity, your principal place of business is in the EEA or Switzerland) and Meta Platforms, Inc. (if you are located outside of the EEA or Switzerland).
62-
By clicking “I Accept” below or by using or distributing any portion or element of the Llama Materials, you agree to be bound by this Agreement.
63-
1. License Rights and Redistribution.
64-
a. Grant of Rights. You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Meta’s intellectual property or other rights owned by Meta embodied in the Llama Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Llama Materials.
65-
b. Redistribution and Use.
66-
i. If you distribute or make the Llama Materials, or any derivative works thereof, available to a third party, you shall provide a copy of this Agreement to such third party.
67-
ii. If you receive Llama Materials, or any derivative works thereof, from a Licensee as part of an integrated end user product, then Section 2 of this Agreement will not apply to you.
68-
iii. You must retain in all copies of the Llama Materials that you distribute the following attribution notice within a “Notice” text file distributed as a part of such copies: “Llama 2 is licensed under the LLAMA 2 Community License, Copyright © Meta Platforms, Inc. All Rights Reserved.”
69-
iv. Your use of the Llama Materials must comply with applicable laws and regulations (including trade compliance laws and regulations) and adhere to the Acceptable Use Policy for the Llama Materials (available at https://ai.meta.com/llama/use-policy), which is hereby incorporated by reference into this Agreement.
70-
v. You will not use the Llama Materials or any output or results of the Llama Materials to improve any other large language model (excluding Llama 2 or derivative works thereof).
71-
2. Additional Commercial Terms. If, on the Llama 2 version release date, the monthly active users of the products or services made available by or for Licensee, or Licensee’s affiliates, is greater than 700 million monthly active users in the preceding calendar month, you must request a license from Meta, which Meta may grant to you in its sole discretion, and you are not authorized to exercise any of the rights under this Agreement unless or until Meta otherwise expressly grants you such rights.
72-
3. Disclaimer of Warranty. UNLESS REQUIRED BY APPLICABLE LAW, THE LLAMA MATERIALS AND ANY OUTPUT AND RESULTS THEREFROM ARE PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE LLAMA MATERIALS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE LLAMA MATERIALS AND ANY OUTPUT AND RESULTS.
73-
4. Limitation of Liability. IN NO EVENT WILL META OR ITS AFFILIATES BE LIABLE UNDER ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT, FOR ANY LOST PROFITS OR ANY INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, EVEN IF META OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
74-
5. Intellectual Property.
75-
a. No trademark licenses are granted under this Agreement, and in connection with the Llama Materials, neither Meta nor Licensee may use any name or mark owned by or associated with the other or any of its affiliates, except as required for reasonable and customary use in describing and redistributing the Llama Materials.
76-
b. Subject to Meta’s ownership of Llama Materials and derivatives made by or for Meta, with respect to any derivative works and modifications of the Llama Materials that are made by you, as between you and Meta, you are and will be the owner of such derivative works and modifications.
77-
c. If you institute litigation or other proceedings against Meta or any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Llama Materials or Llama 2 outputs or results, or any portion of any of the foregoing, constitutes infringement of intellectual property or other rights owned or licensable by you, then any licenses granted to you under this Agreement shall terminate as of the date such litigation or claim is filed or instituted. You will indemnify and hold harmless Meta from and against any claim by any third party arising out of or related to your use or distribution of the Llama Materials.
78-
6. Term and Termination. The term of this Agreement will commence upon your acceptance of this Agreement or access to the Llama Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein. Meta may terminate this Agreement if you are in breach of any term or condition of this Agreement. Upon termination of this Agreement, you shall delete and cease use of the Llama Materials. Sections 3, 4 and 7 shall survive the termination of this Agreement.
79-
7. Governing Law and Jurisdiction. This Agreement will be governed and construed under the laws of the State of California without regard to choice of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement. The courts of California shall have exclusive jurisdiction of any dispute arising out of this Agreement.

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,30 @@ The visualization of the output is like:
589589
----
590590

591591
# 4. Gradio Demos 🎨
592+
## 4.1 Gradio Demo for UPN
593+
We provide a gradio demo for UPN to visualize the object proposals generated by UPN. You can run the following command to start the gradio demo:
594+
```bash
595+
python gradio_demos/upn_demo.py
596+
# if there is permission error, please run the following command
597+
mkdir tmp
598+
TMPDIR='/tmp' python gradio_demos/upn_demo.py
599+
```
600+
601+
<div align=center>
602+
<img src="assets/upn_gradio.jpg" width=600 >
603+
</div>
592604

593-
# 5. LICENSE
594605

595-
This project is licensed under the IDEA LICENSE 1.0 - see the [LICENSE](LICENSE) file for details.
606+
## 4.2 Gradio Demo for ChatRex
596607

597608

609+
# 5. LICENSE
610+
611+
ChatRex is licensed under the IDEA License 1.0, Copyright (c) IDEA. All Rights Reserved. Note that this project utilizes certain datasets and checkpoints that are subject to their respective original licenses. Users must comply with all terms and conditions of these original licenses including but not limited to the:
612+
- [OpenAI Terms of Use](https://openai.com/policies/terms-of-use) for the dataset.
613+
- For the LLM used in this project, the model is [lmsys/vicuna-7b-v1.5](https://huggingface.co/lmsys/vicuna-7b-v1.5/tree/main), which is licensed under [Llama 2 Community License Agreement](https://huggingface.co/lmsys/vicuna-7b-v1.5).
614+
- For the high resolution vision encoder, we are using [laion/CLIP-convnext_large_d.laion2B-s26B-b102K-augreg](https://huggingface.co/laion/CLIP-convnext_large_d.laion2B-s26B-b102K-augreg) which is licensed under [MIT LICENSE](https://huggingface.co/datasets/choosealicense/licenses/blob/main/markdown/mit.md).
615+
- For the low resolution vision encoder, we are using [openai/clip-vit-large-patch14](https://huggingface.co/openai/clip-vit-large-patch14) which is licensed under [MIT LICENSE](https://github.com/openai/CLIP/blob/main/LICENSE)
598616
# BibTeX 📚
599617
```
600618
@misc{jiang2024trex2,

assets/upn_gradio.jpg

524 KB
Loading

chatrex/upn/inference_wrapper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
import numpy as np
66
import torch
7-
import chatrex.upn.transforms.transform as T
87
from mmengine import Config
98
from PIL import Image
109
from torchvision.ops import nms
1110

11+
import chatrex.upn.transforms.transform as T
1212
from chatrex.upn import build_architecture
1313
from chatrex.upn.models.module import nested_tensor_from_tensor_list
1414

@@ -212,7 +212,10 @@ def filter(self, result: Dict, min_score: float, nms_value: float = 0.8):
212212
scores = torch.tensor(scores, dtype=torch.float32)
213213

214214
# Apply Non-Maximum Suppression (NMS)
215-
keep_indices = nms(boxes, scores, nms_value)
215+
if nms_value > 0:
216+
keep_indices = nms(boxes, scores, nms_value)
217+
else:
218+
keep_indices = torch.arange(len(boxes))
216219

217220
# Keep only the boxes that passed NMS
218221
filtered_boxes = boxes[keep_indices].numpy().astype(np.int32)

gradio_demos/chatrex_demo.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import torch
2+
from PIL import Image
3+
from transformers import AutoModelForCausalLM, AutoProcessor, GenerationConfig
4+
5+
from chatrex.tools.visualize import visualize_chatrex_output
6+
from chatrex.upn import UPNWrapper
7+
8+
processor = AutoProcessor.from_pretrained(
9+
"checkpoints/chatrex7b",
10+
trust_remote_code=True,
11+
device_map="cuda",
12+
)
13+
14+
print(f"loading chatrex model...")
15+
# load chatrex model
16+
model = AutoModelForCausalLM.from_pretrained(
17+
"checkpoints/chatrex7b",
18+
trust_remote_code=True,
19+
use_safetensors=True,
20+
).to("cuda")
21+
22+
# load upn model
23+
print(f"loading upn model...")
24+
ckpt_path = "checkpoints/upn_checkpoints/upn_large.pth"
25+
model_upn = UPNWrapper(ckpt_path)
26+
27+
if __name__ == '__main__':
28+

gradio_demos/upn_demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ def get_proposal(
3838

3939
if use_fine_grained:
4040
prompt_type = "fine_grained_prompt"
41-
else:
41+
if use_coarse_grained:
4242
prompt_type = "coarse_grained_prompt"
4343
proposals = model.inference(image, prompt_type=prompt_type)
4444
filtered_proposals = model.filter(
4545
proposals, min_score=float(score_threshold), nms_value=float(nms_value)
4646
)
4747
visualized_image, _ = plot_boxes_to_image(
4848
image.copy(),
49-
filtered_proposals["original_xyxy_boxes"],
50-
filtered_proposals["scores"],
49+
filtered_proposals["original_xyxy_boxes"][0],
50+
filtered_proposals["scores"][0],
5151
point_width=draw_width,
5252
return_point=draw_points,
5353
return_score=return_score,
@@ -76,7 +76,7 @@ def get_proposal(
7676
maximum=1.0,
7777
step=0.01,
7878
)
79-
nms_value = gr.Textbox(label="NMS", value=-1)
79+
nms_value = gr.Textbox(label="NMS", value=0.8)
8080
draw_width = gr.Slider(
8181
label="draw_width",
8282
value=10,

0 commit comments

Comments
 (0)