Spaces:
Runtime error
Runtime error
Commit
·
23e4842
1
Parent(s):
c2938c1
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
from transformers import AlignProcessor, AlignModel
|
5 |
+
from transformers import AzureOpenAiAgent, OpenAiAgent
|
6 |
+
|
7 |
+
agent = OpenAiAgent(model="text-davinci-003", api_key="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")
|
8 |
+
agent.run("Is the following `text` (in Spanish) positive or negative?", text="¡Este es un API muy agradable!")
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
def predict(text):
|
13 |
+
agent.run("Is the following `text` (in French) positive or negative?", text=text)
|
14 |
+
|
15 |
+
|
16 |
+
description = """
|
17 |
+
"""
|
18 |
+
|
19 |
+
gr.Interface(
|
20 |
+
fn=predict,
|
21 |
+
inputs=[
|
22 |
+
gr.inputs.Textbox(lines=1, placeholder="Enter text",)
|
23 |
+
],
|
24 |
+
theme="grass",
|
25 |
+
outputs="label",
|
26 |
+
examples=[
|
27 |
+
["My name is Antoine",],
|
28 |
+
],
|
29 |
+
title="Images vs labels créé avec ALIGN et Huggingface",
|
30 |
+
description=description
|
31 |
+
).launch()
|