vijayvizag commited on
Commit
2a1cdbf
·
1 Parent(s): 22d57c6

Initial commit for Hugging Face Space

Browse files
README.md CHANGED
@@ -12,3 +12,25 @@ short_description: doc gen
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  ---
13
 
14
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
15
+ # Code to Project Document Generator
16
+
17
+ This is a Streamlit app that takes code files and a heading structure, and generates:
18
+ - A DOCX project report
19
+ - A PPTX presentation
20
+
21
+ It uses lightweight models like T5 and tools like python-docx and pptx. Deployable on Hugging Face Spaces!
22
+
23
+ ## Usage
24
+ 1. Upload your code files (Python or React)
25
+ 2. Upload a `headings.txt` file with your report headings
26
+ 3. Click Generate
27
+
28
+ ## Output
29
+ - `project_report.docx`
30
+ - `project_presentation.pptx`
31
+
32
+ ## Run Locally
33
+ ```bash
34
+ pip install -r requirements.txt
35
+ streamlit run app.py
36
+ ```
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils.summarizer import summarize_code
3
+ from utils.doc_generator import generate_document, generate_pptx
4
+ import os
5
+
6
+ st.title("📄 Code to Project Document Generator")
7
+ st.write("Upload your code files and a headings.txt file.")
8
+
9
+ uploaded_files = st.file_uploader("Upload code files (Python/React)", accept_multiple_files=True)
10
+ headings_file = st.file_uploader("Upload headings.txt", type="txt")
11
+
12
+ if st.button("Generate Document") and uploaded_files and headings_file:
13
+ with open("headings.txt", "wb") as f:
14
+ f.write(headings_file.read())
15
+
16
+ code_dir = "uploaded_code"
17
+ os.makedirs(code_dir, exist_ok=True)
18
+
19
+ for file in uploaded_files:
20
+ with open(os.path.join(code_dir, file.name), "wb") as f:
21
+ f.write(file.read())
22
+
23
+ sections = summarize_code(code_dir, "headings.txt")
24
+ generate_document(sections)
25
+ generate_pptx(sections)
26
+
27
+ st.success("Documents generated!")
28
+ st.download_button("Download DOCX", data=open("project_report.docx", "rb"), file_name="project_report.docx")
29
+ st.download_button("Download PPTX", data=open("project_presentation.pptx", "rb"), file_name="project_presentation.pptx")
headings.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ABSTRACT
2
+ Introduction
3
+ Python
4
+ Machine Learning
5
+ Deep Learning
6
+ Image Classification
7
+ Working of Image Classification
8
+ Applications of Image Classification
9
+ Architecture
10
+ Data Flow Diagram
11
+ Image Classification Techniques
12
+ Aim of the Project
13
+ Scope
14
+ System Requirements
15
+ Hardware Requirements
16
+ Software Requirements
17
+ Setup Instructions
18
+ Algorithms
19
+ Performance Evaluation
20
+ Comparison of Base Line Models
21
+ Error Analysis
22
+ Methodology
23
+ Results
24
+ Discussion
25
+ CONCLUSION
26
+ REFERENCES
27
+ FUTURE WORK
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ transformers
3
+ sentencepiece
4
+ docx
5
+ python-pptx
6
+ plantuml
7
+ huggingface-hub
sample_code/sample.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Sample Python file
2
+ def greet(name):
3
+ return f"Hello, {name}!"
utils/doc_generator.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from docx import Document
2
+ from pptx import Presentation
3
+ from pptx.util import Inches
4
+
5
+ def generate_document(sections):
6
+ doc = Document()
7
+ doc.add_heading("Project Report", 0)
8
+ for title, content in sections.items():
9
+ doc.add_heading(title, level=1)
10
+ doc.add_paragraph(content)
11
+ doc.save("project_report.docx")
12
+
13
+ def generate_pptx(sections):
14
+ prs = Presentation()
15
+ for title, content in sections.items():
16
+ slide = prs.slides.add_slide(prs.slide_layouts[1])
17
+ slide.shapes.title.text = title
18
+ slide.placeholders[1].text = content
19
+ prs.save("project_presentation.pptx")
utils/summarizer.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+
3
+ summarizer = pipeline("summarization", model="t5-small")
4
+
5
+ def summarize_code(code_dir, headings_path):
6
+ sections = {}
7
+ with open(headings_path, "r") as hfile:
8
+ headings = [line.strip() for line in hfile if line.strip()]
9
+
10
+ for heading in headings:
11
+ combined_code = ""
12
+ for root, _, files in os.walk(code_dir):
13
+ for file in files:
14
+ with open(os.path.join(root, file), "r", encoding="utf-8", errors="ignore") as f:
15
+ combined_code += f.read() + "\n"
16
+
17
+ summary = summarizer(combined_code[:1000], max_length=120, min_length=30, do_sample=False)[0]["summary_text"]
18
+ sections[heading] = summary
19
+
20
+ return sections