Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	first pass
Browse files- app.py +71 -0
- requirements.txt +3 -0
    	
        app.py
    CHANGED
    
    | @@ -0,0 +1,71 @@ | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            import gradio as gr
         | 
| 2 | 
            +
            from huggingface_hub import HfApi
         | 
| 3 | 
            +
            from datasets import load_dataset, Dataset
         | 
| 4 | 
            +
            import os
         | 
| 5 | 
            +
            import uuid
         | 
| 6 | 
            +
            import json
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # Set your HF credentials
         | 
| 9 | 
            +
            HF_TOKEN = os.getenv("HF_TOKEN")  # In Space, add as a secret variable
         | 
| 10 | 
            +
            DATASET_REPO = "your-username/submitted-papers"  # Replace with your dataset repo
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            # Load dataset (or create dummy if doesn't exist)
         | 
| 13 | 
            +
            def append_to_dataset(entry):
         | 
| 14 | 
            +
                try:
         | 
| 15 | 
            +
                    # Load current dataset
         | 
| 16 | 
            +
                    dataset = load_dataset(DATASET_REPO, split="train", token=HF_TOKEN)
         | 
| 17 | 
            +
                    data = dataset.to_list()
         | 
| 18 | 
            +
                except Exception:
         | 
| 19 | 
            +
                    data = []
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                # Append new entry
         | 
| 22 | 
            +
                data.append(entry)
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                # Save locally and push
         | 
| 25 | 
            +
                new_dataset = Dataset.from_list(data)
         | 
| 26 | 
            +
                new_dataset.push_to_hub(DATASET_REPO, token=HF_TOKEN)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            def submit_paper(title, authors, abstract, category, paper_url, originality):
         | 
| 29 | 
            +
                if not originality:
         | 
| 30 | 
            +
                    return "You must confirm that this is your own submission."
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                entry = {
         | 
| 33 | 
            +
                    "id": str(uuid.uuid4()),
         | 
| 34 | 
            +
                    "title": title,
         | 
| 35 | 
            +
                    "authors": authors,
         | 
| 36 | 
            +
                    "abstract": abstract,
         | 
| 37 | 
            +
                    "category": category,
         | 
| 38 | 
            +
                    "url": paper_url
         | 
| 39 | 
            +
                }
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                append_to_dataset(entry)
         | 
| 42 | 
            +
                return "β
 Submission successful!"
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            # Gradio interface
         | 
| 45 | 
            +
            with gr.Blocks() as demo:
         | 
| 46 | 
            +
                gr.Markdown("## π Submit Your Paper")
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                with gr.Row():
         | 
| 49 | 
            +
                    title = gr.Textbox(label="Title", placeholder="Enter paper title")
         | 
| 50 | 
            +
                    authors = gr.Textbox(label="Authors", placeholder="Jane Doe, John Smith")
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                abstract = gr.Textbox(label="Abstract", lines=6)
         | 
| 53 | 
            +
                category = gr.Dropdown(
         | 
| 54 | 
            +
                    label="Category",
         | 
| 55 | 
            +
                    choices=["NLP", "CV", "Audio", "Theory", "Robotics", "Other"],
         | 
| 56 | 
            +
                    value="NLP"
         | 
| 57 | 
            +
                )
         | 
| 58 | 
            +
                paper_url = gr.Textbox(label="Paper URL (arXiv or PDF)", placeholder="https://...")
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                originality = gr.Checkbox(label="I confirm this is my own work")
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                submit_btn = gr.Button("Submit")
         | 
| 63 | 
            +
                output = gr.Textbox(label="Status", interactive=False)
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                submit_btn.click(
         | 
| 66 | 
            +
                    fn=submit_paper,
         | 
| 67 | 
            +
                    inputs=[title, authors, abstract, category, paper_url, originality],
         | 
| 68 | 
            +
                    outputs=output
         | 
| 69 | 
            +
                )
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            demo.launch()
         | 
    	
        requirements.txt
    CHANGED
    
    | @@ -0,0 +1,3 @@ | |
|  | |
|  | |
|  | 
|  | |
| 1 | 
            +
            gradio
         | 
| 2 | 
            +
            datasets
         | 
| 3 | 
            +
            huggingface_hub
         | 
