Youssouf Traore commited on
Commit
fc82ada
·
1 Parent(s): 99d0dc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +107 -55
app.py CHANGED
@@ -21,12 +21,14 @@ Exemple : 12,5 devient 12.5
21
  Contact : +241065362371"""
22
 
23
 
24
- description_ocr = """Quand tu finis d'importer le texte sélectionne le et copie le !!!!"""
 
 
25
 
26
  title_f = "Travail argumentative"
27
  description_french = " Esseu je dois encore expliquer ?"
28
 
29
- #app 1
30
 
31
  import requests
32
 
@@ -48,15 +50,18 @@ def infer(im):
48
  for output in res.json()["response"]["output"]:
49
  text += output["block_text"]
50
  for poly in output["bounding_poly"]:
51
- blocks.append({
52
- "text": "".join([c["class"] for c in poly["classes"]]),
53
- "rect": poly["dimensions"]
54
- })
 
 
55
 
56
  return text
57
 
58
 
59
- #app 2
 
60
 
61
  def gpt(prompt):
62
  if not prompt:
@@ -71,21 +76,25 @@ def gpt(prompt):
71
  prompt=f_prompt,
72
  temperature=0.9,
73
  max_tokens=3500,
74
- top_p=1)
 
75
 
76
  answer = response.choices[0].text.strip()
77
  print(answer)
78
  return answer
79
 
80
- def gpt_francais(french_prompt,choix):
 
81
  if not french_prompt:
82
  return "Veuillez saisir un thème ."
83
  fi_prompt = """Je veux faire mon travail de français de niveau lycé sous la forme d'un travail argumentatif . La question du travail est la suivante: f"{french_prompt}". tu devras {choix} ce thème. jai besoin dune introduction(avec une problématique et l'annonce du plan), de 3 arguments(avec explication et example et illustration) et d'une conclusion avec une ouverture(donné sous forme de phrase interogative ) """
84
- response = openai.Completion.create(model="text-davinci-003",
85
- prompt=fi_prompt,
86
- temperature=0.9,
87
- max_tokens=3900,
88
- top_p=1)
 
 
89
  answer = response.choices[0].text.strip()
90
  print(answer)
91
  return answer
@@ -134,13 +143,12 @@ CONCLUSION
134
  1. Bilan de la réflexion:
135
  -Résumer les grandes parties de la réflexion
136
  2. Prise de position"""
137
-
138
  response = openai.Completion.create(
139
- model="text-davinci-003",prompt=haha,temperature=0.9,
140
- max_tokens=3500,
141
- top_p=1)
142
  answer = response.choices[0].text.strip()
143
-
144
  return answer
145
 
146
 
@@ -155,41 +163,85 @@ def calcul(math, francais, physique, svt, philo, eps, thea, hist, anglais):
155
  anglais = anglais * 2
156
  hist = hist * 3
157
  conduite = 14 * 1
158
- total = math + francais + physique + svt + philo + eps + thea + hist + anglais + conduite
159
- r = total/28
160
- return matha.trunc(r*100)/100
161
-
162
-
163
-
164
- #interface 1
165
- app1 = gr.Interface(fn = infer,title="Mariam -Ocr ",description=description_ocr, inputs=[gr.Image(type="pil")], outputs=["text"])
166
-
167
- #interface 2
168
- app2 = gr.Interface(fn = gpt,title="Mariam-U", description=description, inputs=gr.Textbox(label="Question:",lines=8), outputs=gr.Textbox())
169
-
170
- #interface3
171
-
172
- app3 = gr.Interface(fn =gpt_francais,title="Mariam-French",
173
- title = title_f, description=description_french, inputs=[ gr.Textbox(label="Sujet:",lines=8),gr.Radio(["Etaye", "refute"])] ,outputs=gr.Textbox())
174
-
175
-
176
- #interface4
177
-
178
- app4 = gr.Interface(fn =gpt_philo,title="Mariam-Philo",
179
- title= "Dissertation philo", description="Ah..banana banana...", inputs=gr.Textbox(label="Sujet:",lines=8),outputs=gr.Textbox())
180
-
181
- #interface5
182
- app5 = gr.Interface(fn=calcul, inputs=[gr.inputs.Number(label="Math"),
183
- gr.inputs.Number(label="Français"),
184
- gr.inputs.Number(label="Physique"),
185
- gr.inputs.Number(label="SVT"),
186
- gr.inputs.Number(label="Philo"),
187
- gr.inputs.Number(label="EPS"),
188
- gr.inputs.Number(label="Théâtre"),
189
- gr.inputs.Number(label="Histoire"),
190
- gr.inputs.Number(label="Anglais")
191
- ], outputs = gr.Textbox(label="Moyenne"), title=title_c, description=description_c)
192
-
193
- demo = gr.TabbedInterface([app1, app2,app3,app4,app5], ["OCR", "MARIAM-u","Mariam-French","Mariam-Philo","Note Calc"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
 
195
  demo.launch()
 
21
  Contact : +241065362371"""
22
 
23
 
24
+ description_ocr = (
25
+ """Quand tu finis d'importer le texte sélectionne le et copie le !!!!"""
26
+ )
27
 
28
  title_f = "Travail argumentative"
29
  description_french = " Esseu je dois encore expliquer ?"
30
 
31
+ # app 1
32
 
33
  import requests
34
 
 
50
  for output in res.json()["response"]["output"]:
51
  text += output["block_text"]
52
  for poly in output["bounding_poly"]:
53
+ blocks.append(
54
+ {
55
+ "text": "".join([c["class"] for c in poly["classes"]]),
56
+ "rect": poly["dimensions"],
57
+ }
58
+ )
59
 
60
  return text
61
 
62
 
63
+ # app 2
64
+
65
 
66
  def gpt(prompt):
67
  if not prompt:
 
76
  prompt=f_prompt,
77
  temperature=0.9,
78
  max_tokens=3500,
79
+ top_p=1,
80
+ )
81
 
82
  answer = response.choices[0].text.strip()
83
  print(answer)
84
  return answer
85
 
86
+
87
+ def gpt_francais(french_prompt, choix):
88
  if not french_prompt:
89
  return "Veuillez saisir un thème ."
90
  fi_prompt = """Je veux faire mon travail de français de niveau lycé sous la forme d'un travail argumentatif . La question du travail est la suivante: f"{french_prompt}". tu devras {choix} ce thème. jai besoin dune introduction(avec une problématique et l'annonce du plan), de 3 arguments(avec explication et example et illustration) et d'une conclusion avec une ouverture(donné sous forme de phrase interogative ) """
91
+ response = openai.Completion.create(
92
+ model="text-davinci-003",
93
+ prompt=fi_prompt,
94
+ temperature=0.9,
95
+ max_tokens=3900,
96
+ top_p=1,
97
+ )
98
  answer = response.choices[0].text.strip()
99
  print(answer)
100
  return answer
 
143
  1. Bilan de la réflexion:
144
  -Résumer les grandes parties de la réflexion
145
  2. Prise de position"""
146
+
147
  response = openai.Completion.create(
148
+ model="text-davinci-003", prompt=haha, temperature=0.9, max_tokens=3500, top_p=1
149
+ )
 
150
  answer = response.choices[0].text.strip()
151
+
152
  return answer
153
 
154
 
 
163
  anglais = anglais * 2
164
  hist = hist * 3
165
  conduite = 14 * 1
166
+ total = (
167
+ math
168
+ + francais
169
+ + physique
170
+ + svt
171
+ + philo
172
+ + eps
173
+ + thea
174
+ + hist
175
+ + anglais
176
+ + conduite
177
+ )
178
+ r = total / 28
179
+ return matha.trunc(r * 100) / 100
180
+
181
+
182
+ # interface 1
183
+ app1 = gr.Interface(
184
+ fn=infer,
185
+ title="Mariam -Ocr ",
186
+ description=description_ocr,
187
+ inputs=[gr.Image(type="pil")],
188
+ outputs=["text"],
189
+ )
190
+
191
+ # interface 2
192
+ app2 = gr.Interface(
193
+ fn=gpt,
194
+ title="Mariam-U",
195
+ description=description,
196
+ inputs=gr.Textbox(label="Question:", lines=8),
197
+ outputs=gr.Textbox(),
198
+ )
199
+
200
+ # interface3
201
+
202
+ app3 = gr.Interface(
203
+ fn=gpt_francais,
204
+ title="Mariam-French",
205
+ title=title_f,
206
+ description=description_french,
207
+ inputs=[gr.Textbox(label="Sujet:", lines=8), gr.Radio(["Etaye","refute"])],
208
+ outputs=gr.Textbox(),
209
+ )
210
+
211
+
212
+ # interface4
213
+
214
+ app4 = gr.Interface(
215
+ fn=gpt_philo,
216
+ title="Mariam-Philo",
217
+ title="Dissertation philo",
218
+ description="Ah..banana banana...",
219
+ inputs=gr.Textbox(label="Sujet:", lines=8),
220
+ outputs=gr.Textbox(),
221
+ )
222
+
223
+ # interface5
224
+ app5 = gr.Interface(
225
+ fn=calcul,
226
+ inputs=[
227
+ gr.inputs.Number(label="Math"),
228
+ gr.inputs.Number(label="Français"),
229
+ gr.inputs.Number(label="Physique"),
230
+ gr.inputs.Number(label="SVT"),
231
+ gr.inputs.Number(label="Philo"),
232
+ gr.inputs.Number(label="EPS"),
233
+ gr.inputs.Number(label="Théâtre"),
234
+ gr.inputs.Number(label="Histoire"),
235
+ gr.inputs.Number(label="Anglais"),
236
+ ],
237
+ outputs=gr.Textbox(label="Moyenne"),
238
+ title=title_c,
239
+ description=description_c,
240
+ )
241
+
242
+ demo = gr.TabbedInterface(
243
+ [app1, app2, app3, app4, app5],
244
+ ["OCR", "MARIAM-u", "Mariam-French", "Mariam-Philo", "Note Calc"],
245
+ )
246
 
247
  demo.launch()