anas-awadalla commited on
Commit
3d4e892
1 Parent(s): 71de382
app.py CHANGED
@@ -8,7 +8,7 @@ login(token=os.environ["HUGGINGFACE_TOKEN"])
8
 
9
  demo_imgs = [
10
  ["images/chinchilla_web-1024x683.jpg", "images/shiba-inu-dog-in-the-snow.jpg"],
11
- ["images/900.jpeg", "images/hummus.jpg"],
12
  ["images/COCO_train2014_000000572279.jpg", "images/COCO_train2014_000000194806.jpg"],
13
  [
14
  "images/bcee7a-20190225-a-london-underground-sign.jpg",
@@ -25,6 +25,8 @@ demo_texts = [
25
  [
26
  "Output: a pink flamingo standing in a body of water.",
27
  "Output: a bowl filled with creamy hummus placed on a white countertop.",
 
 
28
  ],
29
  [
30
  "Question: Describe the scene. Answer: A white airplane being repaired on the runway. 'Cargo' is written on it in red.",
@@ -32,10 +34,6 @@ demo_texts = [
32
  ],
33
  ['Output: "Underground"', 'Output: "Congress Ave"'],
34
  ["Output: 2 dogs", "Output: 3 pandas"],
35
- [
36
- "Output: Step 1: Cook 8 oz. of pasta until al dente, then drain and set aside. Step 2: In a food processor, blend 2 cups fresh basil leaves, 1/2 cup grated Parmesan cheese, 1/2 cup pine nuts, 2 cloves garlic, and 1/4 cup olive oil until smooth. Step 3: Toss the pesto sauce with the cooked pasta until evenly coated. Step 4: Serve hot and enjoy!",
37
- "Output: Step 1: Drain and rinse a can of chickpeas. Step 2: Add chickpeas to a food processor along with 2-3 cloves of garlic, 2 tbsp of tahini, 2 tbsp of lemon juice, and 1/4 cup of olive oil. Step 3: Process until smooth, scraping down the sides as needed. Step 4: Add salt and pepper to taste. Step 5: If the hummus is too thick, add water 1 tbsp at a time until desired consistency is reached. Step 6: Serve with a drizzle of olive oil and some paprika for garnish. Enjoy!",
38
- ],
39
  ]
40
 
41
  # cd to open_flamingo dir and pip install .
@@ -52,12 +50,12 @@ with open("bad_words.txt", "r") as f:
52
  model, image_processor, tokenizer = create_model_and_transforms(
53
  clip_vision_encoder_pretrained="openai",
54
  clip_vision_encoder_path="ViT-L-14",
55
- lang_encoder_path="togethercomputer/RedPajama-INCITE-Instruct-3B-v1",
56
- tokenizer_path="togethercomputer/RedPajama-INCITE-Instruct-3B-v1",
57
  cross_attn_every_n_layers=2,
58
  )
59
 
60
- checkpoint_path = hf_hub_download("openflamingo/OpenFlamingo-4B-vitl-rpj3b-langinstruct", "checkpoint.pt")
61
  model.load_state_dict(torch.load(checkpoint_path), strict=False)
62
 
63
  model.eval()
@@ -169,7 +167,7 @@ def generate(
169
  with gr.Blocks() as demo:
170
  # As a consequence, you should treat this model as a research prototype and not as a production-ready model. Before using this demo please familiarize yourself with our [model card](https://github.com/mlfoundations/open_flamingo/blob/main/MODEL_CARD.md) and [terms and conditions](https://github.com/mlfoundations/open_flamingo/blob/main/TERMS_AND_CONDITIONS.md)
171
  gr.Markdown(
172
- """
173
  # 🦩 OpenFlamingo Demo
174
 
175
  Blog posts: #1 [An open-source framework for training vision-language models with in-context learning](https://laion.ai/blog/open-flamingo/) // #2 [OpenFlamingo v2: New Models and Enhanced Training Setup]()\n
@@ -183,9 +181,9 @@ RedPajama-INCITE-Instruct-3B-v1.
183
 
184
  with gr.Accordion("See terms and conditions"):
185
  gr.Markdown("""**Please read the following information carefully before proceeding.**
186
- [OpenFlamingo-4B](https://huggingface.co/openflamingo/OpenFlamingo-4B-vitl-rpj3b-langinstruct) is a **research prototype** that aims to enable users to interact with AI through both language and images. AI agents equipped with both language and visual understanding can be useful on a larger variety of tasks compared to models that communicate solely via language. By releasing an open-source research prototype, we hope to help the research community better understand the risks and limitations of modern visual-language AI models and accelerate the development of safer and more reliable methods.
187
  **Limitations.** OpenFlamingo-4B is built on top of the [
188
- RedPajama-INCITE-Instruct-3B-v1](https://huggingface.co/togethercomputer/RedPajama-INCITE-Instruct-3B-v1) large language model developed by MosaicML. Large language models are trained on mostly unfiltered internet data, and have been shown to be able to produce toxic, unethical, inaccurate, and harmful content. On top of this, OpenFlamingo’s ability to support visual inputs creates additional risks, since it can be used in a wider variety of applications; image+text models may carry additional risks specific to multimodality. Please use discretion when assessing the accuracy or appropriateness of the model’s outputs, and be mindful before sharing its results.
189
  **Privacy and data collection.** This demo does NOT store any personal information on its users, and it does NOT store user queries.""")
190
  read_tc = gr.Checkbox(
191
  label="I have read and agree to the terms and conditions", value=False)
 
8
 
9
  demo_imgs = [
10
  ["images/chinchilla_web-1024x683.jpg", "images/shiba-inu-dog-in-the-snow.jpg"],
11
+ ["images/900.jpeg", "images/hummus.jpg", "images/london-underground-sign.jpg", "images/COCO_train2014_000000194806.jpg"],
12
  ["images/COCO_train2014_000000572279.jpg", "images/COCO_train2014_000000194806.jpg"],
13
  [
14
  "images/bcee7a-20190225-a-london-underground-sign.jpg",
 
25
  [
26
  "Output: a pink flamingo standing in a body of water.",
27
  "Output: a bowl filled with creamy hummus placed on a white countertop.",
28
+ "Output: a red and blue 'Underground' sign found in London",
29
+ "Output: Two people flying a white kite on a beach."
30
  ],
31
  [
32
  "Question: Describe the scene. Answer: A white airplane being repaired on the runway. 'Cargo' is written on it in red.",
 
34
  ],
35
  ['Output: "Underground"', 'Output: "Congress Ave"'],
36
  ["Output: 2 dogs", "Output: 3 pandas"],
 
 
 
 
37
  ]
38
 
39
  # cd to open_flamingo dir and pip install .
 
50
  model, image_processor, tokenizer = create_model_and_transforms(
51
  clip_vision_encoder_pretrained="openai",
52
  clip_vision_encoder_path="ViT-L-14",
53
+ lang_encoder_path="togethercomputer/RedPajama-INCITE-Base-3B-v1",
54
+ tokenizer_path="togethercomputer/RedPajama-INCITE-Base-3B-v1",
55
  cross_attn_every_n_layers=2,
56
  )
57
 
58
+ checkpoint_path = hf_hub_download("openflamingo/OpenFlamingo-4B-vitl-rpj3b", "checkpoint.pt")
59
  model.load_state_dict(torch.load(checkpoint_path), strict=False)
60
 
61
  model.eval()
 
167
  with gr.Blocks() as demo:
168
  # As a consequence, you should treat this model as a research prototype and not as a production-ready model. Before using this demo please familiarize yourself with our [model card](https://github.com/mlfoundations/open_flamingo/blob/main/MODEL_CARD.md) and [terms and conditions](https://github.com/mlfoundations/open_flamingo/blob/main/TERMS_AND_CONDITIONS.md)
169
  gr.Markdown(
170
+ """
171
  # 🦩 OpenFlamingo Demo
172
 
173
  Blog posts: #1 [An open-source framework for training vision-language models with in-context learning](https://laion.ai/blog/open-flamingo/) // #2 [OpenFlamingo v2: New Models and Enhanced Training Setup]()\n
 
181
 
182
  with gr.Accordion("See terms and conditions"):
183
  gr.Markdown("""**Please read the following information carefully before proceeding.**
184
+ [OpenFlamingo-4B](https://huggingface.co/openflamingo/OpenFlamingo-4B-vitl-rpj3b) is a **research prototype** that aims to enable users to interact with AI through both language and images. AI agents equipped with both language and visual understanding can be useful on a larger variety of tasks compared to models that communicate solely via language. By releasing an open-source research prototype, we hope to help the research community better understand the risks and limitations of modern visual-language AI models and accelerate the development of safer and more reliable methods.
185
  **Limitations.** OpenFlamingo-4B is built on top of the [
186
+ RedPajama-INCITE-Base-3B-v1](https://huggingface.co/togethercomputer/RedPajama-INCITE-Base-3B-v1) large language model developed by Together.xyz. Large language models are trained on mostly unfiltered internet data, and have been shown to be able to produce toxic, unethical, inaccurate, and harmful content. On top of this, OpenFlamingo’s ability to support visual inputs creates additional risks, since it can be used in a wider variety of applications; image+text models may carry additional risks specific to multimodality. Please use discretion when assessing the accuracy or appropriateness of the model’s outputs, and be mindful before sharing its results.
187
  **Privacy and data collection.** This demo does NOT store any personal information on its users, and it does NOT store user queries.""")
188
  read_tc = gr.Checkbox(
189
  label="I have read and agree to the terms and conditions", value=False)
images/{bcee7a-20190225-a-london-underground-sign.jpg → london-underground-sign.jpg} RENAMED
File without changes