Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
classifier = pipeline("text_classification", model="Prakhar618/Gptdetect")
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def predict(text):
|
| 8 |
+
# Convert test dataframe to Hugging Face dataset
|
| 9 |
+
test_dataset = Dataset.from_pandas(text)
|
| 10 |
+
|
| 11 |
+
# Apply the tokenization function to the train dataset
|
| 12 |
+
train_dataset = test_dataset.map(tokenize_function, batched=True,)
|
| 13 |
+
predictions, label_probs, _ = trainer.predict(train_dataset1)
|
| 14 |
+
y_pred = np.argmax(predictions, axis=1)
|
| 15 |
+
return y_pred
|
| 16 |
+
|
| 17 |
+
iface = gr.Interface(fn=predict, inputs="text", outputs="text")
|
| 18 |
+
iface.launch()
|