shubhammukherjee commited on
Commit
6b672ec
·
verified ·
1 Parent(s): f7687c4

created an app

Browse files
Files changed (1) hide show
  1. app.py +31 -30
app.py CHANGED
@@ -1,37 +1,38 @@
1
- import bpy
 
2
 
3
- # Set up a basic scene with a camera and light
4
- def setup_scene():
5
- # Clear existing objects
6
- bpy.ops.object.select_all(action='SELECT')
7
- bpy.ops.object.delete()
8
 
9
- # Add a camera
10
- bpy.ops.object.camera_add(location=(0, -5, 3))
11
- camera = bpy.context.active_object
12
- camera.rotation_euler = (1.109, 0, 0)
13
-
14
- # Set the camera as active
15
- bpy.context.scene.camera = camera
16
-
17
- # Add a light source
18
- bpy.ops.object.light_add(type='POINT', location=(0, 0, 5))
19
 
20
- # Add a cube to animate
21
- bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0))
22
- cube = bpy.context.active_object
23
- cube.name = 'Cube'
24
 
25
- # Keyframe animation (for example, move the cube)
26
- cube.location = (0, 0, 0)
27
- cube.keyframe_insert(data_path="location", frame=1)
 
 
28
 
29
- cube.location = (5, 5, 0)
30
- cube.keyframe_insert(data_path="location", frame=50)
 
31
 
32
- # Set the frame range for the animation
33
- bpy.context.scene.frame_start = 1
34
- bpy.context.scene.frame_end = 50
 
 
 
 
 
35
 
36
- # Execute the setup function
37
- setup_scene()
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
 
4
+ # Title of the app
5
+ st.title("Hugging Face Transformers with Streamlit")
 
 
 
6
 
7
+ # Sidebar for selecting model
8
+ st.sidebar.header("Select a Model")
 
 
 
 
 
 
 
 
9
 
10
+ model_option = st.sidebar.radio("Choose a task", ["Text Generation", "Text Summarization", "Sentiment Analysis"])
 
 
 
11
 
12
+ # Load the transformer model based on selected task
13
+ if model_option == "Text Generation":
14
+ st.header("Text Generation")
15
+ model = pipeline("text-generation", model="gpt2")
16
+ user_input = st.text_area("Enter your prompt:", "Once upon a time")
17
 
18
+ if st.button("Generate Text"):
19
+ result = model(user_input, max_length=100, num_return_sequences=1)
20
+ st.write(result[0]["generated_text"])
21
 
22
+ elif model_option == "Text Summarization":
23
+ st.header("Text Summarization")
24
+ model = pipeline("summarization", model="facebook/bart-large-cnn")
25
+ user_input = st.text_area("Enter the text to summarize:", "The quick brown fox jumps over the lazy dog.")
26
+
27
+ if st.button("Summarize Text"):
28
+ result = model(user_input, min_length=25, max_length=100, length_penalty=2.0, num_beams=4, early_stopping=True)
29
+ st.write(result[0]["summary_text"])
30
 
31
+ elif model_option == "Sentiment Analysis":
32
+ st.header("Sentiment Analysis")
33
+ model = pipeline("sentiment-analysis")
34
+ user_input = st.text_area("Enter the text to analyze:", "I love programming!")
35
+
36
+ if st.button("Analyze Sentiment"):
37
+ result = model(user_input)
38
+ st.write(f"Sentiment: {result[0]['label']}, Confidence: {result[0]['score']:.2f}")