myownskyW7 commited on
Commit
7a8a021
1 Parent(s): 405c819

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -0
README.md CHANGED
@@ -27,6 +27,31 @@ We release InternLM-XComposer2 series in two versions:
27
  - InternLM-XComposer2-VL: The pretrained VLLM model with InternLM2 as the initialization of the LLM, achieving strong performance on various multimodal benchmarks.
28
  - InternLM-XComposer2: The finetuned VLLM for *Free-from Interleaved Text-Image Composition*.
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  ### Import from Transformers
31
  To load the InternLM-XComposer2-VL-7B model using Transformers, use the following code:
32
  ```python
 
27
  - InternLM-XComposer2-VL: The pretrained VLLM model with InternLM2 as the initialization of the LLM, achieving strong performance on various multimodal benchmarks.
28
  - InternLM-XComposer2: The finetuned VLLM for *Free-from Interleaved Text-Image Composition*.
29
 
30
+ ## Quickstart
31
+ We provide a simple example to show how to use InternLM-XComposer with 🤗 Transformers.
32
+ ```python
33
+ import torch
34
+ from transformers import AutoModel, AutoTokenizer
35
+
36
+ torch.set_grad_enabled(False)
37
+
38
+ # init model and tokenizer
39
+ model = AutoModel.from_pretrained('internlm/internlm-xcomposer2-vl-7b', trust_remote_code=True).cuda().eval()
40
+ tokenizer = AutoTokenizer.from_pretrained('internlm/internlm-xcomposer2-vl-7b', trust_remote_code=True)
41
+
42
+ query = '<ImageHere>Please describe this image in detail.'
43
+ image = './image1.webp'
44
+ with torch.cuda.amp.autocast():
45
+ response, _ = model.chat(tokenizer, query=query, image=image, history=[], do_sample=False)
46
+ print(response)
47
+ #The image features a quote by Oscar Wilde, "Live life with no excuses, travel with no regret,"
48
+ # set against a backdrop of a breathtaking sunset. The sky is painted in hues of pink and orange,
49
+ # creating a serene atmosphere. Two silhouetted figures stand on a cliff, overlooking the horizon.
50
+ # They appear to be hiking or exploring, embodying the essence of the quote.
51
+ # The overall scene conveys a sense of adventure and freedom, encouraging viewers to embrace life without hesitation or regrets.
52
+
53
+ ```
54
+
55
  ### Import from Transformers
56
  To load the InternLM-XComposer2-VL-7B model using Transformers, use the following code:
57
  ```python