Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
|
4 |
-
colorFrom: red
|
5 |
-
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.
|
8 |
-
app_file: app.py
|
9 |
-
pinned: false
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: echo-chatbot
|
3 |
+
app_file: demo4.py
|
|
|
|
|
4 |
sdk: gradio
|
5 |
+
sdk_version: 4.16.0
|
|
|
|
|
6 |
---
|
|
|
|
config.yaml
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
database:
|
2 |
+
host: localhost
|
3 |
+
user: root
|
4 |
+
password: UnionCode1998$
|
5 |
+
database: dashboard
|
demo.html
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="utf-8">
|
5 |
+
<title>Bokeh Plot</title>
|
6 |
+
<style>
|
7 |
+
html, body {
|
8 |
+
box-sizing: border-box;
|
9 |
+
display: flow-root;
|
10 |
+
height: 100%;
|
11 |
+
margin: 0;
|
12 |
+
padding: 0;
|
13 |
+
}
|
14 |
+
</style>
|
15 |
+
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-3.3.2.min.js"></script>
|
16 |
+
<script type="text/javascript">
|
17 |
+
Bokeh.set_log_level("info");
|
18 |
+
</script>
|
19 |
+
</head>
|
20 |
+
<body>
|
21 |
+
<div id="c429a978-fa14-4fcf-b133-a0625193abb7" data-root-id="p1001" style="display: contents;"></div>
|
22 |
+
|
23 |
+
<script type="application/json" id="p1035">
|
24 |
+
{"c140f27e-3847-420c-9a16-ed0ad2baf98f":{"version":"3.3.2","title":"Bokeh Application","roots":[{"type":"object","name":"Figure","id":"p1001","attributes":{"js_event_callbacks":{"type":"map","entries":[["pan",[{"type":"object","name":"CustomJS","id":"p1034","attributes":{"args":{"type":"map","entries":[["vertical_line",{"type":"object","name":"Span","id":"p1033","attributes":{"location":10,"dimension":"height","line_color":"green","line_width":2}}]]},"code":"\n console.log(vertical_line.location);\n vertical_line.change.emit();\n"}}]]]},"x_range":{"type":"object","name":"Range1d","id":"p1010","attributes":{"end":100}},"y_range":{"type":"object","name":"Range1d","id":"p1011","attributes":{"end":100}},"x_scale":{"type":"object","name":"LinearScale","id":"p1012"},"y_scale":{"type":"object","name":"LinearScale","id":"p1013"},"title":{"type":"object","name":"Title","id":"p1008"},"toolbar":{"type":"object","name":"Toolbar","id":"p1009","attributes":{"tools":[{"type":"object","name":"PanTool","id":"p1024","attributes":{"dimensions":"width"}},{"type":"object","name":"WheelZoomTool","id":"p1025","attributes":{"dimensions":"width","renderers":"auto"}},{"type":"object","name":"BoxSelectTool","id":"p1026","attributes":{"renderers":"auto","dimensions":"width","overlay":{"type":"object","name":"BoxAnnotation","id":"p1027","attributes":{"syncable":false,"level":"overlay","visible":false,"left":{"type":"number","value":"nan"},"right":{"type":"number","value":"nan"},"top":{"type":"number","value":"nan"},"bottom":{"type":"number","value":"nan"},"editable":true,"line_color":"black","line_alpha":1.0,"line_width":2,"line_dash":[4,4],"fill_color":"lightgrey","fill_alpha":0.5}}}},{"type":"object","name":"ResetTool","id":"p1032"}]}},"toolbar_location":null,"left":[{"type":"object","name":"LinearAxis","id":"p1019","attributes":{"ticker":{"type":"object","name":"BasicTicker","id":"p1020","attributes":{"mantissas":[1,2,5]}},"formatter":{"type":"object","name":"BasicTickFormatter","id":"p1021"},"major_label_policy":{"type":"object","name":"AllLabels","id":"p1022"},"major_label_text_color":null,"axis_line_color":null,"major_tick_line_color":null,"minor_tick_line_color":null}}],"below":[{"type":"object","name":"LinearAxis","id":"p1014","attributes":{"ticker":{"type":"object","name":"BasicTicker","id":"p1015","attributes":{"mantissas":[1,2,5]}},"formatter":{"type":"object","name":"BasicTickFormatter","id":"p1016"},"major_label_policy":{"type":"object","name":"AllLabels","id":"p1017"},"major_label_text_color":null,"axis_line_color":null,"major_tick_line_color":null,"minor_tick_line_color":null}}],"center":[{"type":"object","name":"Grid","id":"p1018","attributes":{"axis":{"id":"p1014"},"grid_line_color":null}},{"type":"object","name":"Grid","id":"p1023","attributes":{"dimension":1,"axis":{"id":"p1019"},"grid_line_color":null}},{"id":"p1033"}]}}]}}
|
25 |
+
</script>
|
26 |
+
<script type="text/javascript">
|
27 |
+
(function() {
|
28 |
+
const fn = function() {
|
29 |
+
Bokeh.safely(function() {
|
30 |
+
(function(root) {
|
31 |
+
function embed_document(root) {
|
32 |
+
const docs_json = document.getElementById('p1035').textContent;
|
33 |
+
const render_items = [{"docid":"c140f27e-3847-420c-9a16-ed0ad2baf98f","roots":{"p1001":"c429a978-fa14-4fcf-b133-a0625193abb7"},"root_ids":["p1001"]}];
|
34 |
+
root.Bokeh.embed.embed_items(docs_json, render_items);
|
35 |
+
}
|
36 |
+
if (root.Bokeh !== undefined) {
|
37 |
+
embed_document(root);
|
38 |
+
} else {
|
39 |
+
let attempts = 0;
|
40 |
+
const timer = setInterval(function(root) {
|
41 |
+
if (root.Bokeh !== undefined) {
|
42 |
+
clearInterval(timer);
|
43 |
+
embed_document(root);
|
44 |
+
} else {
|
45 |
+
attempts++;
|
46 |
+
if (attempts > 100) {
|
47 |
+
clearInterval(timer);
|
48 |
+
console.log("Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing");
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}, 10, root)
|
52 |
+
}
|
53 |
+
})(window);
|
54 |
+
});
|
55 |
+
};
|
56 |
+
if (document.readyState != "loading") fn();
|
57 |
+
else document.addEventListener("DOMContentLoaded", fn);
|
58 |
+
})();
|
59 |
+
</script>
|
60 |
+
</body>
|
61 |
+
</html>
|
demo1.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import re
|
2 |
+
test_str = """除非按时找到确凿证据,否则释放嫌疑人。根据上述论断,可以推出:
|
3 |
+
A: 如果按时找到确凿证据,那么就不释放嫌疑人
|
4 |
+
B: 若释放了嫌疑人,则是没有按时找到确凿证据
|
5 |
+
C: 只有没按时找到确凿证据,才释放嫌疑人
|
6 |
+
D: 或者按时找到确凿证据,或者释放嫌疑人
|
7 |
+
- 描述:我是一个智能助手,旨在为用户解决问题、提供帮助、提供情感支持。
|
8 |
+
- 名字:小地瓜
|
9 |
+
- 开发公司:小红书
|
10 |
+
- 语言:中文
|
11 |
+
- 知识截止:2023-08-143
|
12 |
+
- 当前时间:/
|
13 |
+
- 语言风格:正常,即不需要过于活泼,也不要过于严肃,正常地回复用户即可。
|
14 |
+
- 长度偏好:适中,尽量根据用户的需求确认回复长短。
|
15 |
+
- 信息延伸度:适当延申,即推测用户的需求,考虑是否要给出更多的额外信息。
|
16 |
+
- 互动性:适当互动,即根据具体问答场景选择是否要回应用户的互动。
|
17 |
+
- 输出格式:Markdown
|
18 |
+
- 创作幻觉尺度:用户假定下允许幻觉,即当用户提出的指令里存在幻觉或允许幻觉存在时,创作的文本可以出现幻觉。
|
19 |
+
- 模糊指令情感关怀?:高情感关怀,即当用户的指令隐含了用户遇到的问题或体现了用户的情绪时,提供适当的情感支持。
|
20 |
+
- 模糊指令回答策略:提供猜测,即当用户的指令不明确时,猜测用户的需求,引导用户进一步描述需求。"""
|
21 |
+
|
22 |
+
#pattern = re.compile(r'[\u4e00-\u9fa5]+') 匹配汉字
|
23 |
+
text = "这是一个包含[苹果,香蕉,橙子]的列表。"
|
24 |
+
|
25 |
+
#(创作)
|
26 |
+
#pattern1 = r'\[?\'?-.*。?\n?\]?\"?\n'
|
27 |
+
#re.sub(r'\[.*?\]', '', text)
|
28 |
+
new_text = re.sub(r'\[?\'.*?\]?\'?\n?', '', test_str)
|
29 |
+
new_text = re.sub(r'\[?\'?-.*。?\n?\]?\"?\n?', '', new_text)
|
30 |
+
|
31 |
+
# (数学)匹配其中以-开头的字符串,但不要去除坐标
|
32 |
+
#new_text = re.sub(r'^- [^-].*\n', '', test_str, flags=re.MULTILINE)
|
33 |
+
#print(new_text)
|
34 |
+
print("-----------------")
|
35 |
+
# (数学)
|
36 |
+
new_text = re.sub(r'^".*?"', '', new_text).removesuffix('\n').removeprefix('\n')
|
37 |
+
print(new_text)
|
demo2.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import AutoTokenizer,AutoFeatureExtractor
|
2 |
+
from datasets import load_dataset, Audio
|
3 |
+
|
4 |
+
# tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
|
5 |
+
# dataset = load_dataset("rotten_tomatoes", split="train")
|
6 |
+
|
7 |
+
# print(tokenizer(dataset[0]["text"]))
|
8 |
+
|
9 |
+
# def tokenization(example):
|
10 |
+
# return tokenizer(example["text"])
|
11 |
+
|
12 |
+
# dataset = dataset.map(tokenization, batched=True)
|
13 |
+
|
14 |
+
# feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base-960h")
|
15 |
+
# dataset = load_dataset("PolyAI/minds14", "en-US", split="train")
|
16 |
+
# print(dataset[0]["audio"])
|
17 |
+
# dataset = dataset.cast_column("audio", Audio(sampling_rate=16_000))
|
18 |
+
# print(dataset[0]["audio"])
|
19 |
+
|
20 |
+
# def preprocess_function(examples):
|
21 |
+
# audio_arrays = [x["array"] for x in examples["audio"]]
|
22 |
+
# inputs = feature_extractor(
|
23 |
+
# audio_arrays, sampling_rate=feature_extractor.sampling_rate, max_length=16000, truncation=True
|
24 |
+
# )
|
25 |
+
# return inputs
|
26 |
+
# dataset = dataset.map(preprocess_function, batched=True)
|
27 |
+
|
28 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained("google/vit-base-patch16-224-in21k")
|
29 |
+
dataset = load_dataset("beans", split="train")
|
30 |
+
|
31 |
+
print(dataset[0]["image"])
|
32 |
+
|
33 |
+
from torchvision.transforms import RandomRotation
|
34 |
+
|
35 |
+
rotate = RandomRotation(degrees=(0, 90))
|
36 |
+
def transforms(examples):
|
37 |
+
examples["pixel_values"] = [rotate(image.convert("RGB")) for image in examples["image"]]
|
38 |
+
return examples
|
39 |
+
|
40 |
+
dataset.set_transform(transforms)
|
41 |
+
print(dataset[0]["pixel_values"])
|
demo3.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 定义一个节点类
|
2 |
+
class TreeNode:
|
3 |
+
def __init__(self, x):
|
4 |
+
self.val = x
|
5 |
+
self.left = None
|
6 |
+
self.right = None
|
7 |
+
|
8 |
+
# 定义生成二叉搜索树的函数
|
9 |
+
def generateTrees(n):
|
10 |
+
if n == 0:
|
11 |
+
return []
|
12 |
+
return generate_trees(1, n)
|
13 |
+
|
14 |
+
def generate_trees(start, end):
|
15 |
+
if start > end:
|
16 |
+
return [None,]
|
17 |
+
all_trees = []
|
18 |
+
for i in range(start, end + 1): # 枚举可行根节点
|
19 |
+
# 获得所有可行的左子树集合
|
20 |
+
left_trees = generate_trees(start, i - 1)
|
21 |
+
# 获得所有可行的右子树集合
|
22 |
+
right_trees = generate_trees(i + 1, end)
|
23 |
+
# 从左子树集合中选出一棵左子树,从右子树集合中选出一棵右子树,拼接到根节点上
|
24 |
+
for l in left_trees:
|
25 |
+
for r in right_trees:
|
26 |
+
curr_tree = TreeNode(i)
|
27 |
+
curr_tree.left = l
|
28 |
+
curr_tree.right = r
|
29 |
+
all_trees.append(curr_tree)
|
30 |
+
return all_trees
|
31 |
+
|
32 |
+
# 测试
|
33 |
+
n = 5
|
34 |
+
trees = generateTrees(n)
|
35 |
+
for tree in trees:
|
36 |
+
print(tree.val) # 打印根节点值
|
demo4.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
def slow_echo(message, history):
|
4 |
+
return message
|
5 |
+
|
6 |
+
demo = gr.ChatInterface(slow_echo).queue().launch()
|
demo6.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import load_dataset
|
2 |
+
import pandas as pd
|
3 |
+
from translate import Translator
|
4 |
+
|
5 |
+
dataset = load_dataset("iamtarun/python_code_instructions_18k_alpaca")
|
6 |
+
|
7 |
+
train_dataset = dataset['train'][900:1000]
|
8 |
+
instruction_list = train_dataset['instruction']
|
9 |
+
input_list = train_dataset['input']
|
10 |
+
output_list = train_dataset['output']
|
11 |
+
|
12 |
+
# translator = Translator(to_lang="zh")
|
13 |
+
# for idx in range(len(instruction_list)):
|
14 |
+
# instruction_list[idx] = translator.translate(instruction_list[idx])
|
15 |
+
|
16 |
+
init_df = pd.DataFrame({'instruction': instruction_list, 'input': input_list, 'output': output_list})
|
17 |
+
|
18 |
+
init_df.to_excel('/Users/yangweipeng/code/excel/python_code_instructions_18k_alpaca.xlsx', index=True)
|
text.md
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
首先,我们需要明确每种食材的体积和保质期,然后根据冰箱的容量和每天的消耗量来计算出最多可以存放的食材数量。我们可以先将食材按照保质期从长到短进行排序,然后从保质期最长的食材开始放入冰箱,直到冰箱放不下为止。在这个过程中,我们需要注意的是,每天需要消耗两份食材,所以在计算可以存放的食材数量时,我们需要考虑到这一点。
|
2 |
+
|
3 |
+
以下是实现这个算法的Python代码:
|
4 |
+
|
5 |
+
```python
|
6 |
+
class Food:
|
7 |
+
def __init__(self, name, width, height, depth, shelf_life, quantity):
|
8 |
+
self.name = name
|
9 |
+
self.width = width
|
10 |
+
self.height = height
|
11 |
+
self.depth = depth
|
12 |
+
self.volume = width * height * depth
|
13 |
+
self.shelf_life = shelf_life
|
14 |
+
self.quantity = quantity
|
15 |
+
|
16 |
+
class Fridge:
|
17 |
+
def __init__(self, width, height, depth, layers):
|
18 |
+
self.width = width
|
19 |
+
self.height = height
|
20 |
+
self.depth = depth
|
21 |
+
self.volume = width * height * depth * layers
|
22 |
+
self.layers = layers
|
23 |
+
|
24 |
+
def store_food(self, foods):
|
25 |
+
foods.sort(key=lambda x: x.shelf_life, reverse=True)
|
26 |
+
total_volume = 0
|
27 |
+
for food in foods:
|
28 |
+
while food.quantity > 0 and total_volume + food.volume <= self.volume:
|
29 |
+
total_volume += food.volume
|
30 |
+
food.quantity -= 1
|
31 |
+
return total_volume
|
32 |
+
|
33 |
+
# Initialize fridge and foods
|
34 |
+
fridges = [Fridge(40, 40, 30, 2), Fridge(40, 40, 30, 2), Fridge(40, 40, 20, 1)]
|
35 |
+
#fridge.layers.append(Fridge(40, 40, 20, 1))
|
36 |
+
|
37 |
+
foods = [
|
38 |
+
Food('A', 10, 25, 5, 1, 4),
|
39 |
+
Food('B', 20, 25, 2, 2, 5),
|
40 |
+
Food('C', 20, 15, 3, 2, 6)
|
41 |
+
]
|
42 |
+
|
43 |
+
# Store foods in the fridge
|
44 |
+
total_volume = 0
|
45 |
+
for fridge in fridges:
|
46 |
+
total_volume += fridge.store_food(foods)
|
47 |
+
|
48 |
+
print(f'The total volume of food stored in the fridge is {total_volume} cm^3.') #The total volume of food stored in the fridge is 15400 cm^3.
|
49 |
+
```
|
50 |
+
|
51 |
+
这段代码首先定义了两个类,分别是食材类和冰箱类。然后,我们初始化了一个冰箱和三种食材,并将食材按照保质期从长到短进行排序。最后,我们调用冰箱的store_food方法,将食材放入冰箱,并打印出存放的食材总体积。
|
52 |
+
每个食材的体积:
|
53 |
+
A: 10cm * 25cm * 5cm = 1250cm³
|
54 |
+
B: 20cm * 25cm * 2cm = 1000cm³
|
55 |
+
C: 20cm * 15cm * 3cm = 900cm³
|
56 |
+
第一层和第二层的有效容积相同,均为:40cm * 40cm * 30cm = 48000cm³
|
57 |
+
第三层有效容积为:40cm * 40cm * 20cm = 32000cm³
|
58 |
+
总容积为:48000cm³ + 48000cm³ + 32000cm³ = 128000cm³
|
59 |
+
由于实际需求远小于冰箱的实际容纳能力,因此可以将两天所需的全部食材A、B、C都放入冰箱中,且不会超过冰箱的任何一层的容量。
|