Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import
|
| 2 |
import numpy as np
|
| 3 |
from transformers import Trainer, AutoTokenizer, XLMRobertaForSequenceClassification
|
| 4 |
import torch
|
|
@@ -22,36 +22,37 @@ def checker(content):
|
|
| 22 |
|
| 23 |
return sum / len(content)
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
#
|
| 36 |
-
|
| 37 |
-
# App-Titel
|
| 38 |
-
gr.Markdown(
|
| 39 |
-
"""
|
| 40 |
-
## 📝 Checker
|
| 41 |
-
Ziehe deine Datei hierhin und lasse den Quality Score errechnen!
|
| 42 |
-
"""
|
| 43 |
-
)
|
| 44 |
-
|
| 45 |
-
# Drag & Drop Datei-Upload
|
| 46 |
-
with gr.Row():
|
| 47 |
-
with gr.Column():
|
| 48 |
-
file_input = gr.File(label="Datei hochladen",file_types=[".txt"])
|
| 49 |
-
|
| 50 |
-
with gr.Column():
|
| 51 |
-
output_text = gr.Textbox(label="Dateiinhalt", lines=10)
|
| 52 |
-
|
| 53 |
-
# Callback zum Verarbeiten der Datei
|
| 54 |
-
file_input.change(process_file, inputs=file_input, outputs=output_text)
|
| 55 |
|
| 56 |
-
#
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
from transformers import Trainer, AutoTokenizer, XLMRobertaForSequenceClassification
|
| 4 |
import torch
|
|
|
|
| 22 |
|
| 23 |
return sum / len(content)
|
| 24 |
|
| 25 |
+
# Setze den Titel und eine moderne Überschrift
|
| 26 |
+
st.title("Checker")
|
| 27 |
+
st.markdown("""
|
| 28 |
+
<style>
|
| 29 |
+
.reportview-container {
|
| 30 |
+
background-color: #f4f4f9;
|
| 31 |
+
}
|
| 32 |
+
h1 {
|
| 33 |
+
color: #4F8BF9;
|
| 34 |
+
}
|
| 35 |
+
footer {
|
| 36 |
+
visibility: hidden;
|
| 37 |
+
}
|
| 38 |
+
</style>
|
| 39 |
+
""", unsafe_allow_html=True)
|
| 40 |
|
| 41 |
+
# Erstelle das Drag&Drop Upload-Feld für alle Dateiformate
|
| 42 |
+
uploaded_file = st.file_uploader("Drag & Drop your file here", type=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
# Prüfen, ob eine Datei hochgeladen wurde
|
| 45 |
+
if uploaded_file is not None:
|
| 46 |
+
# Anzeige des Dateinamens
|
| 47 |
+
st.write(f"File uploaded: {uploaded_file.name}")
|
| 48 |
+
|
| 49 |
+
# Wenn die Datei eine Text- oder CSV-Datei ist, zeige den Inhalt an
|
| 50 |
+
if uploaded_file.name.endswith('.txt') or uploaded_file.name.endswith('.csv'):
|
| 51 |
+
content = uploaded_file.read().decode("utf-8")
|
| 52 |
+
st.text_area("File Content", content, height=300)
|
| 53 |
+
|
| 54 |
+
# Wenn andere Dateiformate hochgeladen werden, zeige eine Nachricht an
|
| 55 |
+
else:
|
| 56 |
+
st.write(f"Unsupported file type: {uploaded_file.name.split('.')[-1]}")
|
| 57 |
+
else:
|
| 58 |
+
st.write("Please upload a file.")
|