Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ os.environ['CURL_CA_BUNDLE'] = ''
|
|
7 |
|
8 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
9 |
|
10 |
-
config = LinearMappingConfig()
|
11 |
model = LinearMapping(config)
|
12 |
model.load_state_dict(torch.load("pytorch_model.bin", map_location=device))
|
13 |
processor = LinearMappingProcessor(config)
|
@@ -35,7 +35,11 @@ def generate_image_captions(image, text):
|
|
35 |
|
36 |
article = "This demo is originated from this paper: [original paper](https://arxiv.org/abs/2209.15162)"
|
37 |
description = """
|
38 |
-
### Expand GPT2's language capabilities to vision with CLIP!
|
|
|
|
|
|
|
|
|
39 |
"""
|
40 |
demo = gr.Interface(
|
41 |
fn=generate_image_captions,
|
@@ -55,4 +59,4 @@ demo = gr.Interface(
|
|
55 |
description=description
|
56 |
)
|
57 |
|
58 |
-
demo.launch()
|
|
|
7 |
|
8 |
device = 'cuda' if torch.cuda.is_available() else 'cpu'
|
9 |
|
10 |
+
config = LinearMappingConfig(image_from_pretrained=False, text_from_pretrained=False)
|
11 |
model = LinearMapping(config)
|
12 |
model.load_state_dict(torch.load("pytorch_model.bin", map_location=device))
|
13 |
processor = LinearMappingProcessor(config)
|
|
|
35 |
|
36 |
article = "This demo is originated from this paper: [original paper](https://arxiv.org/abs/2209.15162)"
|
37 |
description = """
|
38 |
+
### Expand GPT2's language capabilities to vision with CLIP!
|
39 |
+
### Tips:
|
40 |
+
- When no image is provided, the model degrades to a vanilla GPT2-Large!
|
41 |
+
- When no description is provided, the model automatically generates a caption for this image.
|
42 |
+
- Try appending 'Answer:' after your question, the model is more likely to give desired outputs this way.
|
43 |
"""
|
44 |
demo = gr.Interface(
|
45 |
fn=generate_image_captions,
|
|
|
59 |
description=description
|
60 |
)
|
61 |
|
62 |
+
demo.launch(share=True)
|