Spaces:
Runtime error
Runtime error
Commit
·
3fdb0e4
1
Parent(s):
13ad427
Update app.py
Browse files
app.py
CHANGED
@@ -14,23 +14,7 @@ model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-capt
|
|
14 |
|
15 |
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
#def greet(name):
|
20 |
-
# return "Hello " + name +os.environ['HF_TOKENS']
|
21 |
-
|
22 |
-
|
23 |
-
#demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
24 |
-
|
25 |
-
#demo.launch()
|
26 |
-
|
27 |
-
|
28 |
-
#gr.close_all()
|
29 |
-
#gr.Textbox(os.environ['HF_TOKENS'])
|
30 |
-
|
31 |
-
#Image-to-text endpoint
|
32 |
def get_completion(raw_image):
|
33 |
-
#raw_image = Image.open(image).convert('RGB')
|
34 |
|
35 |
text = "a photography of"
|
36 |
inputs = processor(raw_image, text, return_tensors="pt")
|
@@ -39,24 +23,11 @@ def get_completion(raw_image):
|
|
39 |
return processor.decode(out[0], skip_special_tokens=True)
|
40 |
|
41 |
|
42 |
-
# headers = {
|
43 |
-
# "Authorization": f"Bearer {os.environ['HF_TOKENS']}",
|
44 |
-
# "Content-Type": "application/json"
|
45 |
-
# }
|
46 |
-
# data = { "inputs": inputs }
|
47 |
-
# if parameters is not None:
|
48 |
-
# data.update({"parameters": parameters})
|
49 |
-
# response = requests.request("POST",
|
50 |
-
# ENDPOINT_URL,
|
51 |
-
# headers=headers,
|
52 |
-
# data=json.dumps(data))
|
53 |
-
# return json.loads(response.content.decode("utf-8"))
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
|
58 |
gr.close_all()
|
|
|
59 |
demo = gr.Interface(fn=get_completion,
|
|
|
60 |
inputs=[gr.Image(label="Upload image", type="pil")],
|
61 |
outputs=[gr.Textbox(label="Caption")],
|
62 |
title="Image Captioning with BLIP",
|
@@ -68,12 +39,4 @@ demo = gr.Interface(fn=get_completion,
|
|
68 |
|
69 |
|
70 |
|
71 |
-
#demo = gr.Interface(fn=captioner,
|
72 |
-
# inputs=[gr.Image(label="Upload image", type="pil")],
|
73 |
-
#// outputs=[gr.Textbox(label="Caption")],
|
74 |
-
# // title="Image Captioning with BLIP",
|
75 |
-
# // description="Caption any image using the BLIP model",
|
76 |
-
# // allow_flagging="never",
|
77 |
-
# // examples=["christmas_dog.jpeg", "bird_flight.jpeg", "cow.jpeg"])
|
78 |
-
|
79 |
demo.launch()
|
|
|
14 |
|
15 |
|
16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
def get_completion(raw_image):
|
|
|
18 |
|
19 |
text = "a photography of"
|
20 |
inputs = processor(raw_image, text, return_tensors="pt")
|
|
|
23 |
return processor.decode(out[0], skip_special_tokens=True)
|
24 |
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
gr.close_all()
|
28 |
+
description = "Made by : Abdul Samad"
|
29 |
demo = gr.Interface(fn=get_completion,
|
30 |
+
description=description,
|
31 |
inputs=[gr.Image(label="Upload image", type="pil")],
|
32 |
outputs=[gr.Textbox(label="Caption")],
|
33 |
title="Image Captioning with BLIP",
|
|
|
39 |
|
40 |
|
41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
demo.launch()
|