Mai Chí Bảo commited on
Commit
d5b4e6e
·
2 Parent(s): 4773bf7 86f37e7

Merge remote-tracking branch 'refs/remotes/origin/main'

Browse files
Files changed (4) hide show
  1. .github/workflows/main.yml +25 -0
  2. app.py +10 -7
  3. hello.py +0 -1
  4. sample_classification.py +0 -25
.github/workflows/main.yml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ # to run this workflow manually from the Actions tab
7
+ workflow_dispatch:
8
+
9
+ jobs:
10
+ sync-to-hub:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ with:
15
+ fetch-depth: 0
16
+ - name: Add remote
17
+ env:
18
+ HG: ${{secrets.HG}}
19
+ run: git remote add space https://chibao24:[email protected]/spaces/chibao24/demo2
20
+
21
+ - name: Push to hub
22
+ env:
23
+ HG: ${{secrets.HG}}
24
+ run: git push --force https://chibao24:[email protected]/spaces/chibao24/demo2 main
25
+
app.py CHANGED
@@ -1,20 +1,23 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
 
4
  # I add a comt
5
  # Initialize the summarization model
6
  model = pipeline("summarization")
7
 
 
 
 
 
 
 
8
 
9
  def predict(prompt):
10
  summary = model(prompt)[0]["summary_text"]
11
  return summary
12
 
13
 
14
- # Create a Gradio interface
15
- interface = gr.Interface(fn=predict, inputs=gr.Textbox(placeholder="Enter text to summarize", lines=4), outputs="text")
16
-
17
-
18
- # Launch the interface
19
- interface.launch()
20
-
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ <<<<<<< HEAD
5
  # I add a comt
6
  # Initialize the summarization model
7
  model = pipeline("summarization")
8
 
9
+ =======
10
+
11
+ model = pipeline(
12
+ "summarization",
13
+ )
14
+ >>>>>>> refs/remotes/origin/main
15
 
16
  def predict(prompt):
17
  summary = model(prompt)[0]["summary_text"]
18
  return summary
19
 
20
 
21
+ # create an interface for the model
22
+ with gr.Interface(predict, "textbox", "text") as interface:
23
+ interface.launch()
 
 
 
 
hello.py DELETED
@@ -1 +0,0 @@
1
- print ("hello")
 
 
sample_classification.py DELETED
@@ -1,25 +0,0 @@
1
- import numpy as np
2
- from sklearn.linear_model import LogisticRegression
3
-
4
- # Generate random data
5
- X = np.random.randint(0, 100, (1000, 2))
6
- y = np.random.randint(0, 2, 1000)
7
-
8
- # Split the data into training and test sets
9
- X_train = X[:750]
10
- y_train = y[:750]
11
- X_test = X[750:]
12
- y_test = y[750:]
13
-
14
- # Create the classifier
15
- clf = LogisticRegression()
16
-
17
- # Train the classifier
18
- clf.fit(X_train, y_train)
19
-
20
- # Predict the labels of the test set
21
- y_pred = clf.predict(X_test)
22
-
23
- # Evaluate the accuracy of the classifier
24
- accuracy = np.mean(y_pred == y_test)
25
- print("Accuracy:", accuracy)