Spaces:
Configuration error
Configuration error
Delete app3.py
Browse files
app3.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from pymongo import MongoClient
|
| 3 |
-
import pandas as pd
|
| 4 |
-
|
| 5 |
-
# MongoDB'ye bağlanma
|
| 6 |
-
client = MongoClient('mongodb://localhost:27017/')
|
| 7 |
-
db = client['combined_texts']
|
| 8 |
-
collection = db['text']
|
| 9 |
-
|
| 10 |
-
# Model eğitme fonksiyonu (örnek)
|
| 11 |
-
def train_model(filtered_data):
|
| 12 |
-
# Burada model eğitme işlemleri yapılır
|
| 13 |
-
# Örneğin, sadece veri boyutunu döndüren sahte bir model eğitimi
|
| 14 |
-
model_response = {
|
| 15 |
-
'status': 'success',
|
| 16 |
-
'message': 'Model trained successfully!',
|
| 17 |
-
'accuracy': 0.95, # Örnek doğruluk değeri
|
| 18 |
-
'data_size': len(filtered_data)
|
| 19 |
-
}
|
| 20 |
-
return model_response
|
| 21 |
-
|
| 22 |
-
# Gradio uygulaması için fonksiyon
|
| 23 |
-
def train_model_gradio(title,keywords,subheadings):
|
| 24 |
-
# MongoDB'den ilgili verileri çekme
|
| 25 |
-
query = {
|
| 26 |
-
'title': {'$in': title},
|
| 27 |
-
'category': {'$in': keywords.split(',')},
|
| 28 |
-
'subheadings': {'$in': subheadings.split(',')}
|
| 29 |
-
}
|
| 30 |
-
filtered_data = list(collection.find(query))
|
| 31 |
-
|
| 32 |
-
# Model eğitme
|
| 33 |
-
response = train_model(filtered_data)
|
| 34 |
-
return response
|
| 35 |
-
|
| 36 |
-
# Gradio arayüzü
|
| 37 |
-
iface = gr.Interface(
|
| 38 |
-
fn=train_model_gradio,
|
| 39 |
-
inputs=[
|
| 40 |
-
gr.Textbox(label="Title"),
|
| 41 |
-
gr.Textbox(label="Keywords (comma-separated)"),
|
| 42 |
-
gr.Textbox(label="Subheadings (comma-separated)")
|
| 43 |
-
],
|
| 44 |
-
outputs="json",
|
| 45 |
-
title="Model Training Interface",
|
| 46 |
-
description="Enter the titles, categories, subcategories, and subheadings to filter the data and train the model."
|
| 47 |
-
)
|
| 48 |
-
|
| 49 |
-
if __name__ == "__main__":
|
| 50 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|