Spaces:
Runtime error
Runtime error
RitaParadaRamos
commited on
Commit
·
c6d8afa
1
Parent(s):
8253c78
Upload app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,7 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
23 |
feature_extractor = CLIPFeatureExtractor.from_pretrained("openai/clip-vit-base-patch32")
|
24 |
|
25 |
# load and configure tokenizer
|
26 |
-
tokenizer = AutoTokenizer.from_pretrained("facebook/opt-
|
27 |
tokenizer.pad_token = '!'
|
28 |
tokenizer.eos_token = '.'
|
29 |
|
@@ -48,9 +48,9 @@ model= model.to(device)
|
|
48 |
template = open('src/template.txt').read().strip() + ' '
|
49 |
|
50 |
# precompute captions for retrieval
|
51 |
-
captions = json.load(open('coco_index_captions.json'))
|
52 |
retrieval_model, feature_extractor_retrieval = clip.load("RN50x64", device=device)
|
53 |
-
retrieval_index = faiss.read_index('coco_index')
|
54 |
#res = faiss.StandardGpuResources()
|
55 |
#retrieval_index = faiss.index_cpu_to_gpu(res, 0, retrieval_index)
|
56 |
|
@@ -99,4 +99,4 @@ textbox = gr.Textbox(placeholder="Retrieved captions and generated caption...",
|
|
99 |
title = "SmallCap Demo"
|
100 |
gr.Interface(
|
101 |
fn=classify_image, inputs=image, outputs=textbox, title=title
|
102 |
-
).launch()
|
|
|
23 |
feature_extractor = CLIPFeatureExtractor.from_pretrained("openai/clip-vit-base-patch32")
|
24 |
|
25 |
# load and configure tokenizer
|
26 |
+
tokenizer = AutoTokenizer.from_pretrained("facebook/opt-125M")
|
27 |
tokenizer.pad_token = '!'
|
28 |
tokenizer.eos_token = '.'
|
29 |
|
|
|
48 |
template = open('src/template.txt').read().strip() + ' '
|
49 |
|
50 |
# precompute captions for retrieval
|
51 |
+
captions = json.load(open('datastore/coco_index_captions.json'))
|
52 |
retrieval_model, feature_extractor_retrieval = clip.load("RN50x64", device=device)
|
53 |
+
retrieval_index = faiss.read_index('datastore/coco_index')
|
54 |
#res = faiss.StandardGpuResources()
|
55 |
#retrieval_index = faiss.index_cpu_to_gpu(res, 0, retrieval_index)
|
56 |
|
|
|
99 |
title = "SmallCap Demo"
|
100 |
gr.Interface(
|
101 |
fn=classify_image, inputs=image, outputs=textbox, title=title
|
102 |
+
).launch(share=True)
|